我使用ajax timer定时读取数据,但是数据读取一段时间后不读取了,请高手指点!
页面代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"  >
        <ContentTemplate>
            <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeOut="60000">
            </asp:ScriptManager>
            <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick">
            </asp:Timer>
            <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </ContentTemplate>
    </asp:UpdatePanel>
时钟代码如下:
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Random r = new Random();
        TextBox1.Text = Convert.ToString(r.Next());    }

解决方案 »

  1.   

    AsyncPostBackTimeOut="60000">是不是跟这个属生有关系?
      

  2.   

    AsyncPostBackTimeOut="60000"这个是为了防止异步报错,不设置这个也出现那种情况情况就是页面停留在那,我采用一个文本框来读取随机数嘛,每隔2秒读取一次。运行一会后,数据停在那了,不更新了,我在程序里重新设置断点,发现不执行这段代码了
    protected void Timer1_Tick(object sender, EventArgs e)
      {
      Random r = new Random();
      TextBox1.Text = Convert.ToString(r.Next());  }真是郁闷,也查不出问题的根源来