Wednesday, February 11, 2009

Where to craete dymanically created controls in ASP.NET web site?

I have an AST.NET web site with controls I create dynamically according to data I read from the database.
At first I created the controls in the Page_Load event handler. I had a strange problem: sometimes the control's event handler was not called. This happened with check box controls, and mysteriously only the uncheck event of the first checkbox control was not handled.
I found this article about creating dynamic controls:
http://aspnet.4guysfromrolla.com/articles/092904-1.aspx
And moved the call to the function that creates these controls to the Page_Init event handler of my page. Now all events are handled correctly.

No comments:

Post a Comment