1 – Is it possible to handle controls that generate dynamically via java script or other way in page ?
2- What is the mechanism of find control, if I have my TextBox in UpdatePanel ?
For Example how can i get value of controls(textBox) that has been added to table :
for (int i = 0; i < rowsCount; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < colsCount; j++)
{
TableCell cell = new TableCell();
TextBox tb = new TextBox();
tb.ID = "txtSabeghe_" + (i + 1) + "Col_" + (j + 1);
cell.Controls.Add(tb);
row.Cells.Add(cell);
}
Table5.Rows.Add(row);
}
Table And button of Function Both Are in Update Panel to Avoid Postback
Your question is too general, but I’ll do my best to answer based on what I “think” you’re asking.
Yes, all .net controls render as HTML in the DOM so you can handle them exactly as you would a DOM element, except that .net renders DOM with extra stuff in the
idattribute i.e. ctl_001_ etc, so you need to use theClientIDproperty. You can of course set theClientIDModetoStaticin the web.config as this article shows, this will leave the IDs as you specify.And your script.
Control.FindControlis a server side method (of theControlbase class) that takes the ID (as a string) of the control you want to find, which can be used as follows.And in your code behind.
EDIT – Finding a control using master pages
If you want to find your control using master pages, you’re best filtering through the parents like so.