Click here to Skip to main content
16,016,022 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ,

I want to creat textboxes using javascript and jquery so this is what i tried :

ASP.NET
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
            function createtextbox() {
                var txt = "<input id='txt1' type='text'>";
                txt += "</input>";
                $("#MainContent_txtcontainer").append(txt);
            }
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div id="txtcontainer"  runat="server">
        <input id="asa" type="button" value="add" onclick="createtextbox();"  />
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
</asp:Content>


But my question is how i can get the value of those textboxes on server side code and mainly when pressing on the Button1 ?

Thanks.
Posted

(i lost.... sorry for my previous post. i forgot the programmatic creation of controls that cannot access directly from server.)

i found a link that showed the programmatic access of js created control from code behind. but it only showed how to get the value..:
How To Create TextBox Dynamically using Javascript and Read Control Value In Code Behind[^]
 
Share this answer
 
v4
Please Check Below Link, I hope it's helpful for you....

Add Or Remove TextBox Dynamically Using JavaScript in ASP.Net[^]
 
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