Reputation: 1768
I generated a HTMLTextArea
using string
and Response.Write()
:
string area = "<textarea id=\"myArea{0}\" cols=\"30\" name=\"S1\" rows=\"5\" runat=\"server\"></textarea>";
Response.Write(String.Format(area,1));
After this, I don't know how to get the object of this myArea1
.
Are there any way I can achieve this goal?
Upvotes: 0
Views: 691
Reputation: 55288
The proper way to add System.Web.UI.HtmlControls.
will be,
var newTextArea = new HtmlTextArea()
{
ID = string.Format("myArea{0}", 1),
Name = string.Format("S{0}", 1),
Cols = 30,
Rows = 5
};
Page.Controls.Add(newTextArea);
Then you can access it like,
var myTextArea = Page.FindControl("myArea1") as HtmlTextArea;
Upvotes: 1
Reputation: 14521
You don't really need to access the TextArea object itself if you are only interested in getting the user input, which you should be able to find in Request.Form collection on form submission.
Upvotes: 0