AsyncPostBackTrigger不是在我的应用程序工作

AsyncPostBackTrigger不是在我的应用程序工作

本文介绍了AsyncPostBackTrigger不是在我的应用程序工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个有趣的问题。我们使用母版运行一个网站,并在页面中的一个,我需要建立一个更新面板完成后将显示SSID组。

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.

因此​​,在内容placesholders之一,我把这个在:

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" />

背景code是简单的:

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;
}

现在,我遇到的问题是,这是行不通的。它的工作原理,如果我使用PostBackTriggers而不是异步的。然而,这不是我想要的功能。我试图把按钮和定时器到的UpdatePanel无济于事。

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?

推荐答案

此问题现在已经解决了。我所要做的就是增加异步=true将:

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" %>

这篇关于AsyncPostBackTrigger不是在我的应用程序工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 20:56