Registers a control for asynchronous postbacks, which can be used to update specific regions of the page .
Syntax
CSharp
public void RegisterAsyncPostBackControl (
Control control
)
VisualBasic
Public Sub RegisterAsyncPostBackControl ( _
control As Control _
)
ManagedCPlusPlus
public:
virtual void RegisterAsyncPostBackControl (
Control^ control
) sealed
JSharp
public final void RegisterAsyncPostBackControl (
Control control
)
Parameters
- control (Control)
The Control control to register for asynchronous postbacks.
Remarks
The RegisterAsyncPostBackControl(Control) method enables you to register controls to perform an asynchronous postback instead of a synchronous postback which updates the entire page . When the ChildrenAsTriggers property of an UpdatePanel control is set to true (which is the default), postback controls inside the UpdatePanel control are automatically registered as asynchronous postback controls and cause a refresh of the panel content.
Use the RegisterAsyncPostBackControl(Control) method to register controls outside of an UpdatePanel control as postback controls that can perform asynchronous postbacks and potentially update the content of an update panel. To update an UpdatePanel control programmatically, call the Update() method.
If you want to register a control as a trigger for an UpdatePanel control, use the designer's UpdatePanelTrigger Collection Editor dialog box, or add the trigger declaratively by using the <Triggers> element of the UpdatePanel control.
Examples
The following example demonstrates how to call the RegisterAsyncPostBackControl(Control) method to register a Button control so that it causes an update of an UpdatePanel control's content. The Button control is not inside the UpdatePanel control. Two buttons are shown: Button1 and Button2. Button1 refreshes the content of the panel, while Button2 refreshes the entire page.
The following example demonstrates how to call the RegisterAsyncPostBackControl(Control) method to register a user control so that it causes an update of an UpdatePanel control's content. The first example shows a page using the user control. The second example shows the user control.
Controls
<%@ Control Language="C#" ClassName="WebUserControl" %>
<script runat="server">
public event EventHandler InnerClick
{
add
{
UCButton1.Click += value;
}
remove
{
UCButton1.Click -= value;
}
}
public String Name
{
get
{
return UCTextBox1.Text;
}
}
</script>
<asp:Panel ID="UCPanel1" runat="server" GroupingText="User Control">
Enter your name:
<asp:TextBox ID="UCTextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="UCButton1" runat="server" Text="Submit" />
</asp:Panel>
Controls
<%@ Control Language="VB" ClassName="WebUserControl" %>
<script runat="server">
Public Custom Event InnerClick As EventHandler
AddHandler(ByVal value As EventHandler)
AddHandler UCButton1.Click, value
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveHandler UCButton1.Click, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
End RaiseEvent
End Event
Public ReadOnly Property Name() As String
Get
Return UCTextBox1.Text
End Get
End Property
</script>
<asp:Panel ID="UCPanel1" runat="server" GroupingText="User Control">
Enter your name:
<asp:TextBox ID="UCTextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="UCButton1" runat="server" Text="Submit" />
</asp:Panel>
Exceptions
Assembly: System.Web.Extensions (Module: System.Web.Extensions)