Friday, September 11, 2009

How to Add an Event Handler to Control Created in Code Behind

I hope that title makes sense to you. Basically I'm building a big form in the code behind. Sucks. But in my case I had to do it and also had to set AutoPostback and add an EventHandler to some checkboxes.

cb = new CheckBox();
cb.AutoPostBack = true;
cb.CheckedChanged += new System.EventHandler(this.CB_CheckedChanged);


"CB_CheckedChanged" is a method I created to handle the cb checks. You can basically use the same code for RadioButtonLists etc.

No comments:

Post a Comment