asp.net更新面板问题

时间:2015-12-17 16:34:14

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

我试图用ASP.NET AJAX Update Panel做一个简单的加载gif。

标记:

<body>
    <form id="form1" runat="server">
        <div>

            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>

            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Button ID="btnWork" runat="server" OnClick="btnWork_Click" Text="Work" />
                    <asp:Panel ID="Panel1" runat="server" Visible="False">
                        like a spinner jif...
                    </asp:Panel>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnWork" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>

        </div>
    </form>

代码隐藏:

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnWork_Click(object sender, EventArgs e)
    {
        Panel1.Visible = true;
        Thread.Sleep(3000);
        Panel1.Visible = false;
    }
}

问题是Panel1永远不会出现。

0 个答案:

没有答案