tags:

views:

514

answers:

2

I have a page that has 2 dynamically loaded user controls each within it's own update panel. On load of the user controls, I execute javascript that updates the css of the table cells.

ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "Load_RunScript()", true);

Both user controls have a button each that causes a postback and on the server side executes JS for making some change. The issue I run into is when I click on the button on one of the user control (Say UCtlA), the postback causes the user controls to be reloaded dynamically which executes the onload script in UCtlB as well causing the page to perform slow.

Since the UCs are in UpdatePanels, my understanding was the UI should not be re-rendered on postbacks. Why is this happening and what is the solution?

A: 

UpdatePanels cause a Postback similar to the Page postback. To avoid unnecessary work in Pageload check the ScriptManager.IsInAsyncPostback property to detect the UpdatePanel Postback. Only the controls in the UpdatePanel causing the Postback should update their GUI.

ka3751
But in this case, a control in UpdatePanel1 is updating the UpdatePanel2's gui as well!
DotnetDude
A: 

Add the UpdateMode="Conditional" property and possibly ChildrenAsTriggers="false"

http://weblogs.asp.net/alessandro/archive/2008/01/30/reducing-updatepanel-bloat-by-utilizing-updatemode-quot-conditional-quot-and-childrenastriggers-quot-false-quot.aspx

Honestly I would say steer clear of UpdatePanels because they are dogs especially nested UpdatePanels.

TessaresLLC