Click here to Skip to main content
14,883,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The TextChanged event is not firing on a dynamically created TextBox in my ASP.NET form. The code I am using is:
C#
c1 = new TableCell();
c1.VerticalAlign = VerticalAlign.Middle;
cell.Width = 80;
TextBox txtFirst = new TextBox();
txtFirst.ID = "TextBoxRow_" + num_row  + "Col_" + c;
txtFirst.EnableViewState = true;
txtFirst.AutoPostBack = true;
txtFirst.TextChanged += new EventHandler(OnTextChanged);
XML
protected void OnTextChanged(object sender, EventArgs e)
{
  TextBox txtFirst = (TextBox)sender;
  string ID = txtFirst.ID;
  ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert",
    "<script type = 'text/javascript'>alert('" + ID +
    " fired OnTextChanged event');</script>");

  
}
Can anyone help?
Posted
Updated 16-May-12 22:07pm
v4
Comments
Jim Jos 17-May-12 4:27am
   
Have you given Runat=Server??
Parshu2378 17-May-12 4:31am
   
ya given
Jim Jos 17-May-12 4:39am
   
Could you go to view source and cut and past the code which is associated with the control's postback (there should be some javascript_postback function)

Make sure that your id is not changing on postback
   
for that particular textbox make autopostback="True"
   
Comments
Parshu2378 17-May-12 5:45am
   
I have given autopostback = "true" to the text box control (if you see my code i given all properties in code)

thanks,
parshu

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900