原贴在:http://topic.csdn.net/u/20100205/16/057b7012-9ea1-48b9-82ef-af80ad75e3cb.html?seed=252443860&r=63304705#r_63304705ASP.NET AJAX 页面上,按住鼠标滚轮,到其刷新时100%会整页刷新。如果在按住后有上移下移,虽不整页刷新但也不局部刷新。如何解决? 
vs2005+.net2.0+ ajax Extensions(system.web.extensions), 浏览器ie6、ie6sp1、ie7、ie8、360。概率100%。 全部代码如下: 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="t2.aspx.cs" Inherits="t2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>无标题页 </title> 
<script type="text/javascript">status+='5seconds'; </script> 
    
</head> 
<body  onload="setInterval('document.getElementById(\'Button1\').click();',5000);"> 
    <form id="form1" runat="server"> 
    <div> 
        <br /> 
        <img src="abc.jpg" height="500px" width="1200px" alt="让滚轮出现" /> <br /> 
        <br /> 
        <asp:Label ID="Label1" runat="server" Text="Label"> </asp:Label> <!--Page_Load() {Label1.Text = DateTime.Now.ToString()+"整页刷新";}--> 
        <hr /> 
    <asp:scriptmanager ID="Scriptmanager1" runat="server"> </asp:scriptmanager> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
        <asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" /> 
        <asp:Label ID="Label2" runat="server" Text="Label"> </asp:Label> <!--Button1_Click(){Label2.Text = DateTime.Now.ToString()+"局部刷新";}--> 
    </ContentTemplate> 
    </asp:UpdatePanel> 
        &nbsp; <br /> 
        <img src="abc.jpg" height="500px" width="1200px" alt="让滚轮出现" /> <br />        
    </div>    
    </form> 
</body> 
</html> 

解决方案 »

  1.   

    <body  onload="setInterval('document.getElementById(\'Button1\').click();',5000);"> 
    晕!你这个代码都不对。应该是保持
    <body>
    </body>然后,再放一个asp.net ajax 的Timer控件,设置Timer的属性来刷新。
      

  2.   

    回2楼,没有不对。这个直接贴到ajax enabled 网站的aspx里面是可以跑的!
    回3楼。的确是鼠标滚轮键。
    如果不按,跑到电脑待机都没事。
      

  3.   

    试试ajax timer,试试换个电脑
      

  4.   

    我想我应该说明这个是怎么想的。
    我呢,有一个小程序要运行在浏览器中,局部刷新的,并且使用者可以调整其运行的刷新速度、筛选条件等。没有做成applet,而是js程序,也就是“飞地”一般的跑在浏览器中了。
    这个js程序需要数据,需要提交更改的参数,我图方便和兼容,在updatepanel中用了asp.net的Button1,再写Button1_Click,这不就省下很多手写js代码了嘛。然后在页面上用js去“按”它,document.getElementById('Button1').click(),达到目的。似乎就可以达到目的了,但是不行,机器换了6个,原因我也找到了,有两个,
    一个,js定时遇到“鼠标滚轮键”就出问题了!“按住”是指按住后鼠标变成上下左右的箭头。按住没关系,按住后有过移动时js定时就暂停。
    二个,document.getElementById('cotrolid').eventname(),如果操作的是asp.net的控件(Button、LinkButton、select),那就要注意了,如果此时刻鼠标正在按别的东西,正在框选文字,滚轮键正在“按住”,就会出现整页刷新,或者是“对象不支持此属性或方法scriptresource.axd”几万行有错。
    用document.getElementById('Button1').click()的确是不好的,它直接把界面焦点搞掉了。就是不知道怎么可以利用Button1_Click里面的便捷功能,又不需document.getElementById('Button1').click()。
      

  5.   

    ajax Timer用了,的确不会整页刷新了,谢谢。
    没办法和js程序交流?用滚轮的时候还是要暂停?
      

  6.   

    的确是具体问题具体分析。js定时和鼠标滚轮这个问题貌似就是存在且无解且被忽略。我new个date找时间吧。timer和js是不好交流,尤其和extJs框架合不来。日日。
    谢谢各位。