2012-06-29 28 views
0

我正在使用c#編寫asp.net和ajax。我想在用戶點擊按鈕時彈出加載面板。 Mu表單包含3個文本框和一個下拉列表(autopostback = true)和一個提交按鈕。我使用下面的代碼。如何在asp.net中彈出加載面板的特定控件

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

和我的UpdateProgress代碼:

<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的提交按鈕時,如何彈出加載面板。請指導我。

回答

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> 

好運。

相關問題