How to get value from dynamic created Textbox using Params in C#
Hi friend .
If we create dynamic Textbox in Asp.Net and Add it on the Place Holder like this,
public partial class _Default : System.Web.UI.Page
{
string txtId;
TextBox txt = new TextBox();
protected void Page_Load(object sender, EventArgs e)
{
txt.ID = "txt";
PlaceHolder1.Controls.Add(txt);
txtId = txt.UniqueID; // this will give u Unique ID like this "ctl00$ContentPlaceHolder1$txt"
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = Request.Params[txtId].ToString();
}
}
Hope this will help you.
Rajesh
If we create dynamic Textbox in Asp.Net and Add it on the Place Holder like this,
public partial class _Default : System.Web.UI.Page
{
string txtId;
TextBox txt = new TextBox();
protected void Page_Load(object sender, EventArgs e)
{
txt.ID = "txt";
PlaceHolder1.Controls.Add(txt);
txtId = txt.UniqueID; // this will give u Unique ID like this "ctl00$ContentPlaceHolder1$txt"
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = Request.Params[txtId].ToString();
}
}
Hope this will help you.
Rajesh
0 comments: