Skip to content Skip to sidebar Skip to footer

Load Text Into Textarea From Code Behind In Asp.net Using C#

I've one asp.net page and I want to load text into the textArea control which is in aspx page from into a variable in code behind (C#): Code behind: System.Web.UI.HtmlControls.Html

Solution 1:

You should add the

runat="server"

attribute to the text area.

Or, preferable you should use the TextBox ASP.NET control and set the TextMode property to TextBoxMode.MultiLine. Example follows:

Code behind:

Output1.Text = Output.ToString();

ASP:

<divstyle ="width: 78%; float: right; height: 85px; display: block;"class="message_text_box_left"><asp:TextBoxID="Output1"Rows="3"CssClass="message_text_box"ToolTip="Share your ideas here..."TextMode="MultiLine" /></div>

Solution 2:

Add runat="server" in *.aspx file. Use Innertext property to set the text value. E.g.

htmlTexarea.InnerHtml = "sample"

Solution 3:

  1. Add runat="server" to your control
  2. Check your .designer.cs or codebehind .cs file for textarea/textbox declaration and fix it.
  3. Do not use FindControl function (it is not recursive), get control by ID. textarea1.Value = xxx;

Solution 4:

If you add the runat="server" attribute you should be able to use the textarea1.innerText directly.

Solution 5:

Add runat="server" and get value with InnerText from code behind

Post a Comment for "Load Text Into Textarea From Code Behind In Asp.net Using C#"