C# – Dynamically add html to panel and access the htmlcontrols

asp.netchtmlnet

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

Best Answer

for creating dynamic html, put your code in page_init event..