Refresh a Web Forms UpdatePanel from an external button

An UpdatePanel can refresh a region of an existing Web Forms page after a server event. It still runs a server postback and the page lifecycle. Only the rendered update is partial.

This is a .NET Framework Web Forms maintenance technique. ASP.NET Core does not provide System.Web controls or UpdatePanel.

Create a minimal page

Requires a Windows Web Forms application targeting .NET Framework 4.8.1, with ASP.NET enabled in its development host. Add PanelDemo.aspx:

HTML
<%@ Page Language="C#" %>
<!doctype html>
<html><body>
<form id="MainForm" runat="server">
  <asp:ScriptManager ID="Scripts" runat="server" />
  <asp:Button ID="Refresh" runat="server" Text="Refresh" OnClick="Refresh_Click" />
  <asp:UpdatePanel ID="Panel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
      <asp:Label ID="Result" runat="server" Text="Waiting" />
    </ContentTemplate>
    <Triggers>
      <asp:AsyncPostBackTrigger ControlID="Refresh" EventName="Click" />
    </Triggers>
  </asp:UpdatePanel>
</form>
<script runat="server">
protected void Refresh_Click(object sender, EventArgs e)
{
    Result.Text = DateTime.UtcNow.ToString("O");
}
</script>
</body></html>

Open the page and click Refresh. The label changes from Waiting to a UTC timestamp through an asynchronous postback. Use the browser's network panel to distinguish that request from a full document navigation.

Keep triggers scoped

The trigger's control must be resolvable in the relevant naming container. For dynamically created controls, recreate them consistently during the page lifecycle and register asynchronous postback behavior through ScriptManager when a declarative trigger is unsuitable.

Do not put every expensive part of a page inside one large panel. Partial rendering does not eliminate server computation, database work or view-state costs. Use PostBackTrigger for an action that genuinely requires a full postback, such as the classic file-upload control's upload operation.

Official references

UpdatePanel Class (System.Web.UI)
Enables sections of a page to be partially rendered without a postback.
https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.updatepanel?view=netframework-4.8.1
UpdatePanel

Author: Herman Schoenfeld