Reputation: 422
I would like to dynamically add a html to a server control and then I want to have access to each control from this html. If I use the inner html property of a control I can notice the html was added as a literalControl and I would like it to be a html control with some other html controls
ex:
//aspx file
<div id="content" runat="server"><div>
//aspx.cs file
protected void Page_Load(object sender, EventArgs e)
{
content.AddControlsFromHtml("<input type='text' id='textBox' />")
}
//get the control
((HtmlInputText)content.FindControl("textBox")).Value = "hello"
Is this possible?
I need this behaviour to create different layouts for a page
Upvotes: 1
Views: 2564
Reputation: 52241
for creating dynamic html, put your code in page_init event..
Upvotes: 2