Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My requriment is i want to give dinamicaly adding controls in my web page . that means if i click add button dinamicallly add textboxs in my page. like wise how many times if i click add buton such textboxs will apper. how to do.


Thanks in Advance

Sucharitha
Posted

Sample program creating Text box dynamically using java script

<html>
<head>
<title>Dynamic Form</title>
<script language="javascript">
function changeIt()
{
var i = 1;
my_div.innerHTML = my_div.innerHTML +"<br><input type='text' name='mytext'+ i>"
 
}
</script>
</head>
<body>
 
<form name="form" action="post" method="">
<input type="text" name=t1>
<input type="button" value="test" onClick="changeIt()">
<div id="my_div"></div>
 
</body>
</html>
</br>
 
Share this answer
 
Comments
Rajesh Anuhya 30-Dec-11 5:17am    
Good Answer +5
Sridhar Patnayak 30-Dec-11 5:24am    
Thanks Rajesh
I don't know where you are struck up

I used this code
C#
protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox tt = new TextBox();
            form1.Controls.Add(tt);

        }



XML
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"
            style="height: 26px" />
    </div>
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900