Tuesday, September 4, 2007 3:52 PM
We ran into a snag with our current web app project. We have a page with an update panel, which has user controls within it that contain more update panels. We're trying to get the user-control update panels to fire without the main page going through its page_load event, but not having any luck.
Interestingly, there's a way to enable partial post backs...but its a little decieving.
By default, you can set an update panel to run in two update modes: Conditional or Always. Always is the default, and means that any controls that trigger a postback will cause an async call. However if you specify Conditional, then you can specify exactly which control will cause your udpate panel to update.
You can also set "Children as Triggers" to false, which will keep child controls (including those from a nested panel) from refreshing the Update Panel.
So to recap: Two Update Panels, one nested in another; Parent Update Panel has Update Mode set to Conditional and Children As Triggers set to False.
This means that if I click on a button in my nested Update Panel, only that panel should be updated...and that's what you see in the browser: the nested update panel updates a label with the current time while the parent does nothing.
But there's something else behind the scenes going on. If you put breakpoints into the Page_Load of the page for instance, you'll notice that even though the parent Update Panel doesn't visibly update, the Page_Load still fires. So if you have any code assigning session variables, retrieving data, etc. in your Page_Load, that will still execute.
Now, there's obviously a point where you say "Well, you should make sure you're not doign stupid things in your page load then", and you'd be right. But at the same time, you need to remember that just because the screen doesn't update doesn't mean that things aren't happening at the code behind level, and you have to factor that in when you design your presentation layer.
Sorry about this post...I wanted to capture the essence of the issue, but words really don't communicate it well. Look for a short web-cast on this in the near future...I'm curious to try and find a solution to this as well.
D