There are different ways in which you can create dynamic control in ASP.NET.
Here i have given 5 different ways for creating Dynamic controls.
1 : [By using JavaScript]
------------------------------
By using javascript you can create Dynamic controls.
Code :
window.load = createDynamicControl;
function createDynamicControl()
{
document.write("<input type='text' name='txtJS' value='JavaScript Textbox' />");
}
2 : [By using ASP.NET Literal Control]
--------------------------------------
By using Literal control in ASP.NET you can create Dynamic Control.
<asp:Literal ID="ltrDynamicControl" runat="server" Text="I am Literal control" />
The output of the above code at the client end will be - I am Literal Control,
without having any additional tag.
So you can create dynamic controls using this control.
Code :
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ltrDynamicControl.Text = "<input type='text' id='txtDynamicControl' runat='server' value='Literal Textbox' />";
}
}