禁用ASP.net Ajax中的更新进度按钮

您好,我通过asp.net Ajax加载大量数据按钮单击网格视图显示加载消息更新prgress ...在更新进度时间,我必须禁用我的BtnLoadReport按钮。

<td>
     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
</td>
<td>
   &nbsp;</td>
<td>
 &nbsp;</td>
</tr>
  <tr>
    <td>
     <asp:UpdateProgress ID="updProgress"
        AssociatedUpdatePanelID="UpdatePanel1"
        runat="server" oninit="updProgress_Init" onprerender="updProgress_PreRender">
            <ProgressTemplate>            
               <span style="color:green; font-style:italic;">Loading, please wait...</span>            
            </ProgressTemplate>
        </asp:UpdateProgress>
                        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                        <div id="DemoId">
                          <asp:Button ID="BtnLoadReport" runat="server" onclick="BtnLoadReport_Click" 
                Text="LoadReport" Width="176px"  ClientIDMode="Static" OnClientClick="return clickOnLoadReport();" />
                </div>
                           <asp:GridView ID="GridView1" runat="server" Height="170px" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged" Width="438px">
                 </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="BtnLoadReport" EventName="Click" />
                        </Triggers>
                        </asp:UpdatePanel>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>

我的脚本禁用按钮

          <script type="text/javascript">
            var updateProgress = null;
               function clickOnLoadReport() {
               //    This will disable all the children of the div
              var prm = Sys.WebForms.PageRequestManager.getInstance();
              if (prm.get_isInAsyncPostBack()==false) {
              var nodes = document.getElementById("DemoId").getElementsByTagName('*');
               for (var i = 0; i < nodes.length; i++) {

                nodes[i].disabled = true;
                // nodes[i].off("click");
               }
             }
            }
          </script>

但它不会长时间禁用我的按钮,只会在几秒钟内禁用它

  protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.BtnLoadReport);
        }

        protected void BtnLoadReport_Click(object sender, EventArgs e)
        {
           // System.Threading.Thread.Sleep(3000);

                UpdatePanel1.Update();
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(@"CData.Xml");
                GridView1.DataSource = dataSet.Tables[0];
                GridView1.DataBind();

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void updProgress_Init(object sender, EventArgs e)
        {
BtnLoadReport.Enable = false;        
                        }

        protected void updProgress_PreRender(object sender, EventArgs e)
        {
           BtnLoadReport.Enable
 = true;
        }

这上面的事情我试图禁用我的按钮BtnLoadReport更新进度仍然不工作在此先感谢


function clickOnLoadReport() {
        var requestManager = Sys.WebForms.PageRequestManager.getInstance();
        requestManager.add_initializeRequest(CancelPostbackForSubsequentSubmitClicks);

        function CancelPostbackForSubsequentSubmitClicks(sender, args) {
            if (requestManager.get_isInAsyncPostBack() &
        args.get_postBackElement().id == 'BtnLoadReport') {
                args.set_cancel(true);
                document.getElementById("BtnLoadReport").setAttribute("disabled", "disabled");
                //alert('A previous request is still in progress that was issued on clicking ' + args.get_postBackElement().id);
            }
        }
    }

我改变了我的javascript功能,它解决了我的问题

链接地址: http://www.djcxy.com/p/21705.html

上一篇: Disable button on update progress in ASP.net Ajax

下一篇: Getting binary data directly off the windows clipboard