Skip to main content

Why ASP.NET AJAX UpdatePanels are dangerous | Encosia

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Related Lists

Bookmark History

Saved by 6 people (0 private), first by anonymouse user on 2008-09-30


Public Sticky notes

Using JSON, the entire HTTP round trip is 24 bytes, as compared to 872 bytes for the UpdatePanel. That’s roughly a 4,000% improvement, which will only continue to increase with the complexity of the page.

Not only has this reduced our network footprint dramatically, but it eliminates the necessity for the server to instantiate the UpdatePanel’s controls and take them through their life cycles to render the HTML sent back to the browser.

While I’m a proponent of the simplicity inherent in the UpdatePanel, I think that it is crucial that we use them judiciously. In any heavy use situation, they are very rarely the best solution.

Highlighted by ronnblack

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" /> <script language="javascript"> function UpdateTime() { PageMethods.GetCurrentDate(OnSucceeded, OnFailed); }   function OnSucceeded(result, userContext, methodName) { $get('Label1').innerHTML = result; }   function OnFailed(error, userContext, methodName) { $get('Label1').innerHTML = "An error occured."; } </script> <asp:Label runat="server" ID="Label1" Text="Update Me!" /><br /> <input type="button" id="Button2" value="Web Method Update" onclick="UpdateTime();" />

Highlighted by bluecockatoo

[WebMethod] public static string GetCurrentDate() { return DateTime.Now.ToLongDateString(); }

Highlighted by bluecockatoo