Create textbox dynamically without postback

I would like to have a button which onclick would dynamically create a textbox without any postback. I was trying to do it using the update panel but till now I have not managed to do it. Nothing is created on button click. The following is the code I have used:

 <asp:PlaceHolder ID="textboxes" runat="server"/>

     <asp:ScriptManager ID="scriptMgr" runat="server" />
                <asp:UpdatePanel ID="updatePnl" runat="server">
                            <asp:Button id="Button" text="Add Destination" OnClick="btnCreate_Click" runat="server"/>


  protected void btnCreate_Click(object sender, EventArgs e)
             textboxes.Controls.Add(new TextBox() { ID = "txt" + 1 });


This is what I get on aler(container);:

enter image description here


You have to use OnClientClick for creating textbox without postback

<asp:Button id="Button" text="Add Destination" OnClientClick="return CreateTxt(); runat="server"/>

<script type="text/javascript">

function CreateTxt()
    var container = document.getElementById("myContainerDiv");
    var html = document.getElementById('myContainerDiv').innerHTML;
    html = html + "<input type=text ... /><br />";
    container.innerHTML= html;
   return false;


myContainerDiv is the name of div where you want to add textbox.

Use this inside Button click event.

    TextBox t = new TextBox();
    t.ID = "txt";

you can add as many textboxes u want using this..But when postback occurs they are difficult to manage.Refer the below links to know more about dynamic controls and postbacks..

1.Dynamic Web Server Controls and View State

2.Dynamic Web Controls, Postbacks, and View State

I think in Javascript , you can use like this. Hope this helps you...

var element = document.createElement("jsTextBox"); 

    //Assign different attributes to the element.

    element.setAttribute("value", "text");


 ? Second button Event is not happening in Update panel in aspx page
 ? ASP.Net: click event for dynamic button in dynamically created nested update panel is not raised
 ? button click event on update panel not firing in multiple user control
 ? add a panel or label control dynamically to a datagrid
 ? wxPython - problem with nested sizers, a panel and SetSizer / Fit
 ? ExtJS add panel to panel
 ? ExtJS Add panel above already added panel
 ? c# duplicate panels dynamically
 ? Ext JS - create a tool with dynamic tooltip on a panel
 ? Dynamically add Text Fields to a Panel in extjs