Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Dynamically generated Textboxes on textchanged Event and fetching data from them on Button Click
WhatsApp
Parul Agrawal
11y
16
k
0
1
25
Blog
Dynamically generated Textbox.zip
Dynamically generated Textboxes on textchanged Event and fetching data from them on Button Click
Complete Source code of Default3.aspx
<%
@
Page
Language
="C#"
AutoEventWireup
="true"
CodeFile
="Default3.aspx.cs"
Inherits
="Default3"
%>
<!
DOCTYPE
html
PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
="http://www.w3.org/1999/xhtml">
<
head
runat
="server">
<
title
></
title
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server">
<
div
>
No of Textboxes:
<
asp
:
TextBox
ID
="txtNo"
runat
="server"
ontextchanged
="txtNo_TextChanged"
AutoPostBack
="True"></
asp
:
TextBox
>
<
asp
:
Panel
ID
="Panel1"
runat
="server">
<
br
/>
</
asp
:
Panel
>
<
br
/>
<
asp
:
Button
ID
="btn"
runat
="server"
Text
="Submit"
onclick
="btn_Click"
/>
</
div
>
</
form
>
</
body
>
</
html
>
------------------------------------------------------------------------------------------
Complete Code of Default.aspx.cs Page
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
Default3
: System.Web.UI.
Page
{
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
}
protected
void
txtNo_TextChanged(
object
sender,
EventArgs
e)
{
int
a =
Convert
.ToInt32(txtNo.Text);
for
(
int
i = 0; i < a; i++)
{
TextBox
tempBox =
new
TextBox
();
tempBox.ID =
"txtBox_"
+ (i + 1).ToString() ;
Panel1.Controls.Add(tempBox);
}
}
protected
void
btn_Click(
object
sender,
EventArgs
e)
{
int
a =
Convert
.ToInt32(txtNo.Text);
for
(
int
i = 0; i < a; i++)
{
TextBox
tempBox =
new
TextBox
();
string
ss = Request.Form[
"txtBox_"
+ (i + 1).ToString()].ToString();
if
(tempBox !=
null
)
{
Response.Write(
"<table border=1px; Width=60px ><tr><td>"
+ ss +
"<br> "
+
"</td></tr></table>"
);
}
}
}
}
Dynamically generated Textboxes on textchanged Event and fetching data from them on Button Click
Up Next
Uploading Multiple Files by Dynamically generated FileUpload Control in c#.Net
Ebook Download
View all
.NET Interview Questions and Answer: Practical Implementation
Read by 41.8k people
Download Now!
Learn
View all
Membership not found