c# – What is AsyncPostBackTrigger Class?


How should I use and what does this type of class do?


Defines a control and an optional control event as an assíncrono postback control trigger that causes the UpdatePanel control to be updated. Reference Microsoft Developer Network – AsyncPostBackTrigger Class .

Basically, when using UpdatePanel , the controls contained therein has your updated information without taking a refresh on the page, but there is a technique to declare a AsyncPostBackTrigger some control outside the UpdatePanel make this control have the same behavior of those within the UpdatePanel .

An example would be the statement like this:

<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:Button ID="BtnDateTimeNowUpdate" 
                OnClick="BtnDateTimeNowUpdate_Click" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <asp:AsyncPostBackTrigger ControlID="BtnDateTimeNowUpdate" />
                <asp:Label ID="LblDateTimeNow" runat="server" Text=""></asp:Label>

in this simple code, notice that the BtnDateTimeNowUpdate button is outside the UpdatePanel , but has the same behavior as if it were inside it by the simple configuration present in the UpdatePanel :

    <asp:AsyncPostBackTrigger ControlID="BtnDateTimeNowUpdate" />

if this setting wasn't like this, this button would refresh entire page which is normal behavior for WebForm .

It can be used, when a control outside the UpdatePanel , has to interact with the controls inside the UpdatePanel .


Scroll to Top