Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
How to take value from dynamically created textbox when clicking a button('save')?
I tried all the solution in google,but i could not find.
please help me..
Posted

1 solution

Dynamic Textbox should be define as global and you have to add that control into your form like
C#
public partial class _Default : System.Web.UI.Page
{
TextBox dynamicTBox = new TextBox();
       
protected void Page_Load(object sender, EventArgs e)
{
   this.Form.Controls.Add(dynamicTBox);
}
protected void btnSave_Click(object sender, EventArgs e)
{
   Response.Write(dynamicTBox.Text);
}
}


After entering the value into textbox and before clicking on the "save" button, If you do any server event then you will lost your textbox value and in that case you need to store that textbox value into viewstate or into session.

If this helped you then please Vote and Accept as Answer. :rose:
 
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