|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
referencing dynamically created controls
I have web form, which has some of its content created dynamically. I need to access these items when a button is clicked (in the onclick event). So far I have drawn a blank.
Here is the code for the creation (in pre_render): // Selected col CheckBox cb = new CheckBox(); cb.ID = "cbxSub" + _Ids.Keys[ i ]; cb.Text = ""; TableCell cSub = new TableCell(); cSub.Controls.Add( cb ); row.Cells.Add( cSub ); And teh code to get the state of the control (onclick): foreach ( Control ctrl in Page.Controls) { if (ctrl is CheckBox) if ((ctrl as CheckBox).Checked) if ((ctrl.ID != null) && (ctrl.ID.Length > 6) && (ctrl.ID.Substring( 0, 6 ) == "cbxSub")) Session[ ctrl.ID ] = "true"; } What am I doing wrong? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > referencing dynamically created controls |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|