asp.net - How to access Dynamically Generated Controls not knowing their names -


my page generates list of check boxes @ run time. set id of each of these boxes manually assigning each string.format("checkbox_{0}, n} n running number.

how find out list of checkbox controls codebehind? couldn't find them in page.form.controls. placed?

(i can see checked checkboxes in request.form contains client side names of each control.)

thanks.

-

---more info----

my iterative loop adds checkboxes panel control (created in mark-up page) follows:

checkbox checkbox = new checkbox(); checkbox.text = "add list"; checkbox.id = string.format("checkbox_{0}", n.tostring("0")); panel1.controls.add(checkbox); 

the checkboxes show nicely on page. can tick. when submit http post stream contains ticked ones.

on post back, panel1.controls.count 0. when page first generated, panel1.controls.count 200, contained lots of lieteralcontrols layout.

you can use findcontrol method on page object or parent control object find checkbox object. like:

checkbox chx=(checkbox)page.findcontrol("checkbox1"); if(chx!=null) chx.checked = false; 

you can put insode loop like:

for(int i=0;i<n;i++) { checkbox chx=(checkbox)page.findcontrol("checkbox"+n); if(chx!=null) chx.checked = false; } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -