問題
Javascript觸發時UpdateProgress未顯示
解決方法
.aspx
<style type="text/css"> .transparent { zoom: 1; filter: alpha(opacity=50); opacity: 0.5; width: 100%; background-color: Gray; height: 100%; position: absolute; left: 0; top: 0; z-index: 9999999; text-align: center; margin-top: 0px; } </style> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <div id="divMask" class="transparent"> <table width="100%"> <tr> <td style="height: 300px"> <h2> L O A D I N G . . . . . .</h2> </td> </tr> </table> </div> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div style="display: none" id="div1"> <asp:Button ID="btnGetData" runat="server" Text="Button" OnClick="btnGetData_Click" /> </div> </ContentTemplate> <%-- <Triggers> <asp:AsyncPostBackTrigger ControlID="btnGetData" /> </Triggers>--%> </asp:UpdatePanel>.cs
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string processId = UpdateProgress1.ClientID; string btnId = btnGetData.ClientID; string script = string.Format(@" var process = document.getElementById('{1}'); process.style.display = 'block'; var btn = document.getElementById('{0}');btn.click(); btn.click(); ", btnId, processId); ScriptManager.RegisterStartupScript(this, this.GetType(), "disableDiv", script, true); } }
沒有留言:
張貼留言