0

我在 asp dot net 中使用 ajax UpdateProgress 栏,单击按钮,但查询以写入格式执行,但 prrgress 栏不运行如何解决此类问题。请帮我提供进度条的任何解决方案

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
 <title></title>
 <style type="text/css">
    .style1
    {
        width: 100%;
    }
 </style>
 <script language="javascript" type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);
    var postBackElement;
    function InitializeRequest(sender, args) {

        if (prm.get_isInAsyncPostBack())
            args.set_cancel(true);
        postBackElement = args.get_postBackElement();
        if (postBackElement.id == 'Button1')
            $get('UpdateProgress1').style.display = 'block';
    }



    function EndRequest(sender, args) {
        if (postBackElement.id == 'Button1')
            $get('UpdateProgress1').style.display = 'none';
    }



 </script>
 </head>
 <body>
 <form id="form1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">  
   <ContentTemplate>  
  <asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
       </asp:ToolkitScriptManager>

       <table class="style1">
           <tr>
               <td>
                   &nbsp;</td>
               <td>
                   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
               </td>
               <td>
                   <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
               </td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
           </tr>
           <tr>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
           </tr>
           <tr>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
           </tr>
           <tr>
               <td>
                   </td>
               <td>
                   </td>
               <td>
                   <asp:Button ID="Button1" runat="server" onclick="Button1_Click"Text="Button"/>
               </td>
               <td>
                   </td>
               <td>
                  </td>
               <td>
                       </td>
           </tr>
           <tr>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>

               </td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
               <td>
                   &nbsp;</td>
           </tr>
           <tr>
               <td>
                   &nbsp;</td>
               <td>
               </td>
               <td>
              </td>
               <td>
                 </td>
               <td>
                  </td>
               <td>
                 </td>
           </tr>
       </table>


  <asp:UpdateProgress ID="PageUpdateProgress" runat="server">
                        <ProgressTemplate>
                            <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                <ProgressTemplate>
                                 <img src="images/ajax-loader.gif" alt="image missing" />
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </ProgressTemplate>
                    </asp:UpdateProgress>

  </ContentTemplate>
  </asp:UpdatePanel>
  </form>
  </body>
 </html>
4

1 回答 1

0

我想你在prm.add_beginRequest(onPrmBeginRequest);这里错过了一个。

请求开始时必须显示进度:

onPrmBeginRequest = function (sender, args) {
    var postBackElement = args.get_postBackElement();
    if (postBackElement.id == 'Button1') {
        $get('UpdateProgress1').style.display = 'block';
    }
}

因此,将适当的代码块从initializeRequest移至beginRequest.

现在你可以隐藏在endrequest.

注意

除非指定,id否则可能已被 ASP.Net 破坏。clientIDMode因此,请确保您使用的是idlike ctl00_ContentPlaceHolder1_UpdateProgress1

于 2013-10-11T11:21:40.390 回答