So my problem is that I want to add an event handler to a dynamically created CheckBox. I already looked at other ways to do this and decided that creating a dynamic table containing my CheckBox is the best option for me. I did not add these CheckBoxes to the Management Tree because I need to manage the ViewState manually. In any case, my code works in every way, except that my CheckBox CheckChanged event does not fire. I add this event handler to my CheckBox in my pageLoad event, however any page event that I try seems to give me the same results:
CheckBox chbxLv1 = new CheckBox(); chbxLv1.ID = "DymanicallyCreatedIDForIdentification"; chbxLv1.AutoPostBack = true; chbxLv1.CheckedChanged += new EventHandler(this.checkChanged); protected void checkChanged(object sender, EventArgs e) {
I thought this might be a problem with ViewState at the beginning and did a lot of research. Now I think I'm doing something dumb with the addition of an event handler. I'm not sure why this event never fires, but I'm a little new to adding events to the control. Do I need a delegate here?
- Roman
source share