首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ajax UpdateProgress不工作

Ajax UpdateProgress不工作
EN

Stack Overflow用户
提问于 2013-10-11 19:05:04
回答 1查看 518关注 0票数 0

我正在使用asp . net中的ajax UpdateProgress栏,点击按钮,但查询以写入格式执行,但进度栏没有运行如何解决这种类型的problem.plz帮助我给我任何进度条的解决方案

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

发布于 2013-10-11 19:21:40

我想你在这里遗漏了一个prm.add_beginRequest(onPrmBeginRequest);

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

代码语言:javascript
复制
onPrmBeginRequest = function (sender, args) {
    var postBackElement = args.get_postBackElement();
    if (postBackElement.id == 'Button1') {
        $get('UpdateProgress1').style.display = 'block';
    }
}

因此,将适当的代码块从initializeRequest移动到beginRequest

现在,您可以隐藏在endrequest中。

便笺

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19316605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档