views:

318

answers:

2

I am loading a custom ascx control in page_load of the page that hosts it. This creating all sorts of issues with postbacks. Mainly, control (textboxes, dropdowns,etc) states are getting reset before the event handlers can process them.

Does any one have any good examples of how I could handle this?

My site design can be seen here.

I've been told in a previous question that I can let the control manage its own state.

+1  A: 

Viewstate is restored before the page load event, and therefore dynamic controls need to be loaded and added to the page before the page load event or their state won't be restored as you expect. Do it in the Init event instead.

Joel Coehoorn
Do you have an example? My ASP is pathetic..
Matt
This is not true. You can dynamically load controls in Page_Load event just fine. The control will play catch-up. See this http://www.clariusconsulting.net/blogs/vga/archive/2003/08/11/66.aspx
epitka
+2  A: 

This has been asked so many times. Take a look at this for example: http://stackoverflow.com/questions/1001222/setting-the-controltovalidate-on-a-validator/1001270#1001270

epitka