Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retreiving text of a dynamic textbox

Status
Not open for further replies.

shalni

Programmer
Oct 16, 2003
12
0
0
IN
I have a button in a form. when it is clicked, a textbox is dynamically created. Then when the user enters some text in it and clicks on another button i want to response.write the text in that textbox. but i am unable to do that. Please help
 
How is the text box created? If in code then you should have a handle to it.
 
here is the code:

public class Dyntextbox : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button1;


private void Page_Load(object sender, System.EventArgs e)
{

}
public void Button1_clicked(object sender, System.EventArgs e)
{
TextBox txtbox1 = new TextBox();
txtbox1.ID = "textBox1";
txtbox1.TextMode = TextBoxMode.SingleLine;
txtbox1.Enabled = true;
PlaceHolder1.Controls.Add(txtbox1);

}
protected void Button2_clicked(object sender, System.EventArgs e)
{
Response.Write(Request.Form("textbox1")) ;

}


}
 
I replaced the line: Response.Write(Request.Form("textbox1")) ;

with

Response.Write(Request.Form.Get("textBox1").ToString());

Now it is working fine :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top