下面图老师小编跟大家分享如何在搜索结果出来之前让页面显示“等待中...”,一起来学习下过程究竟如何进行吧!喜欢就赶紧收藏起来哦~
【 tulaoshi.com - Web开发 】
  在当前页面点击搜索按纽后,当前页的button onclick事件会生成一个sql语句,然后转到查询结果页面,由于查询可能很费时间,客户要求在这两个页面中加入一个提示用户正在查询,请等待的页,
  具体的查询是在查询结果页面的Page_Load进行的。
  现在的问题是这个中间页面怎么自动转向查询结果页面,如果在Page_Load里写,这个中间页就显示不出来
  有两种比较中肯的解决方法:
  第一种
  1。可以做个公用的用户控件,copy如下代码,样式自己定义
  div id='doing' style='Z-INDEX: 12000; LEFT: 0px; WIDTH: 100%; CURSOR: wait; POSITION: absolute; TOP: 0px; HEIGHT: 100%'
  table width='100%' height='100%' id="Table1"
  tr align='center' valign='middle'
  td 
  table  id="Table2" class="loading"
  tr align='center' valign='middle'
  tdLoading.../td
  /tr
  /table
  /td
  /tr
  /table
  /div
  script language="javascript"
  function ShowWaiting()
  {
  document.getElementById('doing').style.visibility = 'visible';
  }
  function CloseWaiting()
  {
  document.getElementById('doing').style.visibility = 'hidden';
  }
  function MyOnload()
  {
  document.getElementById('doing').style.visibility = 'hidden';
  }
  if (window.onload == null)
  {
  window.onload = MyOnload;
  }
/script
2。在页面中拖入用户控件
  3。在页面中给button加客户端click方法,如下
  protected void Page_Load(object sender, EventArgs e)
  {
          this.Button1.Attributes.Add("onclick", "ShowWaiting();");        
  }
第二种
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)  第一个页面比如first.aspx加入以下js:
  script language="javascript"
      !--
  var _tt;
  function showSending() 
  {_tt=window.open("processwin.aspx",'uploadfileprocess',"toolbar=0,location=0,directories=0,status=0,
  menubar=0,scrollbars=1,resizable=1,top="+dispHeight+",left="+dispWidth+",width=410,height=200",true);           
  return true;
            }
  function closewin()
  {
     if (_tt!=null)
     {
       _tt.close();
     }
  }
  //--
  /script
  body bgColor="silver" onunload="closewin();"
  然后,后台代码first.aspx.cs
  page_load()时,检索按钮加入如下属性:
  btFileUpload.Attributes.Add("onclick","return showSending()");
processwin.aspx页面就是你要的中间页了,上面写上“等待...”
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)
来源:http://www.tulaoshi.com/n/20160219/1619557.html
看过《如何在搜索结果出来之前让页面显示“等待中...”》的人还看了以下文章 更多>>