更新进度控件不在asp.net中工作

时间:2013-01-28 23:13:49

标签: c# asp.net asp.net-ajax

我已将<asp:UpdatePanel>定义为<asp:UpdateProgress>

  <asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="update1" runat="server">
        <ContentTemplate>
            <asp:Label id="lblresult" runat="server"></asp:Label><br /><br />
            <asp:Button ID="btn1" runat="server" Text="Refresh" OnClick="btn1_Click" />    <br />

      </ContentTemplate>
    </asp:UpdatePanel>
     <asp:UpdateProgress ID="up1" runat="server" AssociatedUpdatePanelID="update1">
                <ProgressTemplate>
                        <span style="color:green; font-style:italic;">Loading, please wait...</span>    
                </ProgressTemplate>
    </asp:UpdateProgress>    

按钮事件定义为

protected void btn1_Click(object sender, EventArgs e)
{
    lblresult.Text = "<span style='color:red;'>"+ DateTime.Now.ToString() +"</span>";
}

但是,我没有得到Loading, please wait...

2 个答案:

答案 0 :(得分:1)

<script type="text/javascript">
    var updateProgress = null;

    function postbackButtonClick() {
        updateProgress = $find("<%= uprMaster.ClientID %>");
        window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
        return true;
    }
</script>

<asp:Button runat="server" Text="Search" ID="btnSearch" OnClick="btnSearch_Click" ClientIDMode="Static" OnClientClick="return postbackButtonClick();"   />

答案 1 :(得分:0)

将更新进度放在里面 像这样

<asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="update1" runat="server">
        <ContentTemplate>

          <asp:UpdateProgress ID="up1" runat="server" AssociatedUpdatePanelID="update1">
            <ProgressTemplate>
                    <span style="color:green; font-style:italic;">Loading, please wait...</span>    
            </ProgressTemplate>

        <asp:Label id="lblresult" runat="server"></asp:Label><br /><br />
        <asp:Button ID="btn1" runat="server" Text="Refresh" OnClick="btn1_Click" />    <br />

  </ContentTemplate>
</asp:UpdatePanel>

</asp:UpdateProgress>