AsyncPostBackTrigger not working in my application

I am experiencing an interesting issue. We are running a website using masterpage and in one of the pages, I need to create an update panel that will display group SSID on completion.

So, in one of the content placesholders, I put this in:

<asp:ScriptManager ID="scManagerConfirm" runat="server" />
<asp:Timer ID="tmrStatus" OnTick="tmrStatus_Tick" Enabled="false" runat="server" Interval="5000" />
   <asp:UpdatePanel ID="upnlStatus" runat="server" UpdateMode="Conditional">
      <Triggers>
         <asp:AsyncPostBackTrigger ControlID="btnConfirm" />
         <asp:AsyncPostBackTrigger ControlID="tmrStatus" />
      </Triggers>
      <ContentTemplate>
          <asp:Panel ID="pnlStatus" CssClass="appStoreStatus" Visible="false" runat="server">
             <p><asp:Literal ID="litStatusText" runat="server" Text="<%$ Resources:GRes, StatusProcessing %>"></asp:Literal></p>
          </asp:Panel>
      </ContentTemplate>
   </asp:UpdatePanel>

   <asp:Button ID="btnConfirm" OnClick="btnConfirm_OnClick" Text="<%$ Resources:GRes, Confirm %>" CausesValidation="true" UseSubmitBehavior="false" runat="server" />

background code is simple:

protected enum RequestStatus { Unprocessed, Processed }

protected void Page_Load( object sender, EventArgs e ) {
}

protected void btnConfirm_OnClick( object sender, EventArgs e ) {
   pnlStatus.Visible = true;
   tmrStatus.Enabled = true;
}

protected void tmrStatus_Tick( object sender, EventArgs e ) {
   if (GetStatus() == RequestStatus.Processed) {
      litStatusText.Text = "SSID: " + GetSSID();
      tmrStatus.Enabled = false;
   }
}

private String GetSSID() {
   return "S-12345-1235-1235-1235";
}

private RequestStatus GetStatus() {
   return RequestStatus.Processed;
}

Now, the problem I am experiencing is that this doesn’t work. It works if I use PostBackTriggers and not Async ones. However, that is not the functionality I would want. I have tried to put button and timer into UpdatePanel to no avail.

Any ideas what could be wrong with this?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

This problem is now solved. All I had to do was add Async=”true” to:

<%@ Page Language="C#" MasterPageFile="~/FlipitAdminPortal.Master" AutoEventWireup="true" CodeBehind="AppUpload.aspx.cs" Inherits="FlipitAdminPortal.AppUpload" Async="true" %>

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply