0

我正在使用 c# 处理 asp.net 和 ajax。当用户单击按钮时,我试图弹出加载面板。Mu 表单包含 3 个文本框和一个下拉列表(autopostback=true)和一个提交按钮。我使用以下代码。

 <asp:UpdatePanel ID="updatepanel1" runat="server">
    <ContentTemplate>   
     <asp:TextBox runat="server" ID="txtMI" Width="80px" Height="20px" CssClass="s1">                                       </asp:TextBox>
<asp:TextBox runat="server" ID="txtMI" Width="80px" Height="20px" CssClass="s1"></asp:TextBox>
<asp:TextBox runat="server" ID="txtMI" Width="80px" Height="20px" CssClass="s1"></asp:TextBox>
        <asp:Dropdownlist ID="drpCountries" runat="server" Font-Bold="True" ForeColor="#FF3300"></asp:Dropdownlist>
        <br />
        <asp:Button ID="btnLoad" runat="server" onclick="btnLoad_Click" Text="submit" />
        </ContentTemplate>
        </asp:UpdatePanel>

我的更新进度代码是:

 <asp:UpdateProgress id="updateProgress" runat="server">
     <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                    <asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/avatarloading.gif" AlternateText="Loading ..." ToolTip="Loading ..." style="padding: 10px;position:fixed;top:25%;left:35%;" /><center><span style="color:White;font-weight:bolder;font-size:x-large;"><b>Loading...</b></span></center>
            </div>
     </ProgressTemplate>

</asp:UpdateProgress>

当我点击提交按钮时,我需要弹出加载面板。但是当我在下拉列表中选择一个项目时,它也会弹出加载面板。当我单击仅使用 ajax 的提交按钮时,如何弹出加载面板。请指导我。

4

1 回答 1

0

两件事:您的 DDL 没有 AutoPostBack=true 并尝试修改更新进度的 AssociatedUpdatePanelID 属性。回发也有可能发生得非常快,您无法看到更新进度发生了什么。无论如何,我会检查它是否遇到了 OnSelectedIndexChanged 事件,如果是,则让线程休眠几秒钟,看看您现在是否可以看到加载弹出。这是我为自己工作的示例项目:

代码背后:

public partial class _Default : System.Web.UI.Page
{
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
    }
}

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem>Item 1</asp:ListItem>
                    <asp:ListItem>Item 2</asp:ListItem>
                </asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                Loading.....</ProgressTemplate>
        </asp:UpdateProgress>
    </div>
    </form>
</body>
</html>

祝你好运。

于 2012-06-29T22:33:13.840 回答