c# - Create checkbox next to each label -


i need page maintained, need of stuff programmatically generated. need create checkboxes next normal labels, without touching .aspx file. right generate list labels on page called labels. each label on site has id beginning lbl_, ones supposed have checkbox begin lblx_. want use create said checkboxes:

foreach (label label in labels) {     if (label.id.contains("lblx_"))     {         checkbox cb = new checkbox();         cb.id = "cb_statistikname_" + label.id;          label.controls.addat(0, cb);     } } 

right code replaces labels, same happens when use label.control.add(cb)

you can use page.controls.addat() combination of page.page.controls.indexof()

if(label.parent != null && label.parent.controls.indexof(label) >= 0)     label.parent.controls.addat(label.parent.controls.indexof(label) + 1, cb); 

note :this should done in page preinit events.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -