views:

17

answers:

1

I am programatically adding a control to an aspx page and binding a server side event to an index changed event inside the control. (It's a RadListBox from Telerik's ASP.NET controls) The problem is that on the postback triggered from the control, the event doesn't hit its eventhandler because on the postback the control isn't defined.

Is there a way to handle this without having to retrace the logic taken before and rebuild the controls so the events that stem from it are processed?

What is proper way?

+2  A: 

You should be adding your dynamic controls in the OnInit event, and add them on every postback.

There is no way for the event of a dynamic control to fire unless the control has been recreated on the postback.

Read about the asp.net page lifecycle.

Oded