Surround with UpdatePanel (ASP.NET)

Surrounds a block with <asp:UpdatePanel> tags.

Purpose

If you need to enable ASP.NET AJAX support on your web site, you will frequently need to place content portions onto UpdatePanel controls. Instead of doing this manually, use Surround with UpdatePanel (ASP.NET). It automatically surrounds the selected code block with the required tags.

Availability

Available from the context menu or via shortcuts:

  • when a code block is selected in an ASPX file.

Notes

  • This refactoring uses the selected code block to specify the content template for the newly created UpdatePanel. So, in addition to <asp:UpdatePanel> tags, it also creates nested <ContentTamplate> tags where it places the selected code.
  • Surround with UpdatePanel (ASP.NET) also creates a <ScriptManager> tag above the UpdatePanel declaration, if needed.

Example

<asp:Button runat="server" Text="Button1">

Result:

<asp:ScriptManager id="ScriptManager1" runat="server"/><asp:UpdatePanel id="UpdatePanel1"
    runat="server">
    <contenttemplate>
        <asp:Button runat="server" Text="Button1">
    </contenttemplate>
</asp:UpdatePanel>

Screenshot

rsSurroundWithUpdatePanel