I have a dynamically built table on the page load of my web page containing textboxes with defaults that can be changed by the user. There is also some validation on the user input values (e.g., input can not be less than zero). When the user submits the table, only valid inputs are stored, and the page is refreshed pulling the stored values to populate the table when it is rebuilt. For some reason the textboxes will still display invalid inputs after submitting and reloading the page even though they are not persistent, and this problem does not happen for labels.
Is there something specifically built into the textbox control causing this issue? Is there somewhere storing the state, perhaps (I tried setting the ViewState
flag to false)? Is this just some part of the page lifecycle?
The textbox is built in a method called from the Page_Load event
void Page_Load(object sender, EventArgs e)
{
//page initialization...
ValidateData(); //This is where the current data is verified, and stored if valid
BuildTable(); //This takes that stored value for the text
}
void BuildTable
{
tbTable = new Table();
tbRow = new TableRow();
tbCell = new TableCell();
TextBox tb = new TextBox();
tb.text = some stored value;
tbCell.Controls.Add(tb);
tbRow.Cells.Add(tbCell);
tbTable.Rows.Add(tbRow);
divFromPage.Controls.add(tbTable);
}
If more information is necessary to help with this issue, just let me know.