Note that there are some explanatory texts on larger screens.

plurals
  1. POTextbox array textchanged doesn't fire properly
    text
    copied!<p>In my code I need to make some <code>textboxes[]</code> that will get some information from the database however its working for 50%</p> <pre><code> public static Table tableinfo = new Table(); public static TableRow rowinfo = new TableRow(); public static TextBox[] information = new TextBox[1000]; public static Label[] information1 = new Label[1000]; public static Label[] information2 = new Label[1000]; public static Label[] information3 = new Label[1000]; public static Label[] information4 = new Label[1000]; public static string[] gettext = new string[1000]; public static int textboxes; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { textboxes = 1; for (int i = 0; i &lt; 1000; i++) { Array.Clear(gettext, 0, gettext.Length); Array.Clear(information, 0, information.Length); } } else { } tableinfo.Controls.Clear(); tableinfo.BorderWidth = 1; addtextboxes(); placeholder1.Controls.Add(tableinfo); makeandfilltextboxes(); } public static void makeandfilltextboxes() { for (int i = 0; i &lt; textboxes; i++) { gettext[i] = ""; } for (int i = 0; i &lt; textboxes; i++) { gettext[i] = information[i].Text; //go to database and fetch information information1[i].text = databaseinformation1[i]; information2[i].text = databaseinformation2[i]; information3[i].text = databaseinformation3[i]; information4[i].text = databaseinformation4[i]; } } static void TestForm_TextChanged(object sender, EventArgs e) { makeandfilltextboxes(); tableinfo.Controls.Clear(); tableinfo.BorderWidth = 1; textboxes++; addtextboxes(); } public static void addtextboxes() { for (int i = 0; i &lt; textboxes; i++) { rowinfo = new TableRow(); TableCell cellinfo = new TableCell(); information[i] = new TextBox(); information[i].AutoPostBack = true; information[i].CausesValidation = false; information[i].EnableViewState = true; information[i].Text = gettext[i]; information[i].TextChanged += new EventHandler(TestForm_TextChanged); rowinfo.Cells.Add(cellinfo); cellinfo.Controls.Add(information[i]); tableinfo.Controls.Add(rowinfo); TableCell cellinfo1 = new TableCell(); information1[i] = new Label(); information1[i].EnableViewState = true; information1[i].Text = databaseinformation1[i]; rowinfo.Cells.Add(cellinfo1); cellinfo.Controls.Add(information1[i]); tableinfo.Controls.Add(rowinfo); TableCell cellinfo2 = new TableCell(); information2[i] = new Label(); information2[i].EnableViewState = true; information2[i].Text = databaseinformation2[i]; rowinfo.Cells.Add(cellinfo2); cellinfo.Controls.Add(information2[i]); tableinfo.Controls.Add(rowinfo); TableCell cellinfo3 = new TableCell(); information3[i] = new Label(); information3[i].EnableViewState = true; information3[i].Text = datbaseinformation3[i]; rowinfo.Cells.Add(cellinfo3); cellinfo.Controls.Add(information3[i]); tableinfo.Controls.Add(rowinfo); TableCell cellinfo4 = new TableCell(); information4[i] = new Label(); information4[i].EnableViewState = true; information4[i].Text = databaseinformation4[i]; rowinfo.Cells.Add(cellinfo4); cellinfo.Controls.Add(information4[i]); tableinfo.Controls.Add(rowinfo); } } </code></pre> <p>So as you can see, I'm filling the array's with the value you filled in the information[i] on the value in there i'm looking in the database if i can find something. this is all working perfectly. the only problem is that the <code>information[i].TextChanged += new EventHandler(TestForm_TextChanged);</code> is called in a strange manner.</p> <p>the 1st time you enter a textbox is fires the 2nd time it isn't fired the 3rd time it fires the 4th time it isn't fired and so on</p> <p>If I can fire the <code>TestForm_TextChanged</code> everytime the problem will be fixed.</p> <p>I also have some checkboxes who are having the eventhandler of checkedchanged who are showing the information on the hand of there are checked or not is this causing some problems im working in a updatepanel and have a scriptmanager on my aspx desinger. what is causing this problem?</p> <p>With Google chrome I can use the ENTER and it will work all the time. But the enter doesn't work in Internet Explorer.</p> <p>NOTE: THE CODE THAT I HAVE SEND HERE IS JUST A REPLICA NOT THE REAL CODE. THIS IS DUE THE POLICY OF MY INTERNSHIP.</p> <p>If you need more information about the code be free to ask ill try to be as much detailed as can.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload