Skip to main content

Diigo Home

Why ASP.NET AJAX UpdatePanels are dangerous | Encosia - The Diigo Meta page

encosia.com/...jax-updatepanels-are-dangerous - Cached - Annotated View

Lindsay Donaghe's personal annotations on this page

bluecockatoo
Bluecockatoo bookmarked on 2008-09-30 codesnippets asp.net ajax troubleshooting web development tutorials

Good arguments against over-use of UpdatePanels and some sample script of how to replace their functionality with JSON calls.

  • <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();" />
  • [WebMethod]
    public static string GetCurrentDate()
    {
    return DateTime.Now.ToLongDateString();
    }

This link has been bookmarked by 9 people . It was first bookmarked on 30 Sep 2008, by Lindsay Donaghe.

  • 10 Mar 09
    kiernon
    Kiernon Reiniger

    Good article on the use of EnablePageMethods property of the ScriptManager

    asp.net ajax

  • 17 Nov 08
  • 14 Nov 08
    • 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.

  • 07 Oct 08
  • 30 Sep 08
    bluecockatoo
    Lindsay Donaghe

    Good arguments against over-use of UpdatePanels and some sample script of how to replace their functionality with JSON calls.

    codesnippets asp.net ajax troubleshooting web development tutorials

    • <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();" />
    • [WebMethod]
      public static string GetCurrentDate()
      {
      return DateTime.Now.ToLongDateString();
      }
  • 03 Jul 08