那你至少在Page_Load里调用了那个函数了吗?

解决方案 »

  1.   

    调用了~~单步跟踪执行看到TextBox.Text的值都已经改变了,TextBox.Text的值是从数据库中取出的
    但是页面就是没有显示~~不知道怎么回事!!
      

  2.   

    Page_load函数中设置的是一个定时器,定时器定时触发自定义的那个函数,在自定义函数中改变的TextBox的值
    单步执行看到TextBox的值是改变的,但是页面没有显示~~~
      

  3.   

    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox txtTest;
    protected System.Web.UI.WebControls.TextBox txt;
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.TextBox TextBox2;
    protected EeekSoft.Web.PopupWin PopupWin1;
    protected EeekSoft.Web.PopupWinAnchor PopupWinAnchor1;
    protected System.Timers.Timer t;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!Page.IsPostBack)
    {
    t = new System.Timers.Timer(3000);//实例化Timer类,设置间隔时间为10000毫秒; 
    t.Elapsed += new System.Timers.ElapsedEventHandler(show);
    t.AutoReset = true;
    t.Enabled = true;
    }
    } public void show(object source, System.Timers.ElapsedEventArgs e) 


    SqlConnection conn = new SqlConnection("server=JSJ-005;database=remind;uid=sa");
    string a = "wowo";
    string str = "select * from remind1 where name='"+a.ToString()+"'";
    SqlCommand cmd = new SqlCommand(str,conn);

    if(conn.State.ToString()=="Closed")
    {
    conn.Open();
    }
    SqlDataReader dr = cmd.ExecuteReader();
    if(dr.Read())
    {
    //if(dr.IsDBNull(2).ToString()!=null)
    //{
    //this.TextBox1.Text = dr.GetValue(2).ToString();
    //}
    this.TextBox1.Text = dr.IsDBNull(2)? null :dr.GetValue(2).ToString(); if(TextBox1.Text.ToString()!="")
    {
    PopupWinAnchor1.NewMessage = "afjsdlf";
    //PopupWin1.Message = PopupWinAnchor1.NewMessage.ToString();
    PopupWinAnchor1.NewText = "fffffffffff";
    //PopupWin1.Text=PopupWinAnchor1.NewText.ToString();
    PopupWinAnchor1.NewTitle = "aaaaaaaaaaa";
    //PopupWin1.Title=PopupWinAnchor1.NewTitle.ToString(); 
    PopupWin1.Visible = true;
    PopupWin1.AutoShow = false; }
    }

      

  4.   

    把TIMER的autopostback设为TRUE看看
      

  5.   

    Timer定时在WinForm是比较常用的:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                System.Timers.Timer t = new System.Timers.Timer(10000);
                t.Elapsed+=new System.Timers.ElapsedEventHandler(theout);
                t.AutoReset = true;
                t.Enabled = true;
            }
            public void theout(object source, System.Timers.ElapsedEventArgs e)
            {
                MessageBox.Show("ok");
            }
        }
    }在WEB中一般是在Global.asax中定义System.Timers.Timer对象:
      Global.asax:   
              void   Application_Start(object   sender,   EventArgs   e)     
              {   
                      System.Timers.Timer   timer   =   new   System.Timers.Timer();   
                      timer.Interval   =   1000;   
                      timer.Elapsed   +=   new   System.Timers.ElapsedEventHandler(timer_Elapsed);   
                      timer.Start();   
              }   
        
              void   timer_Elapsed(object   source,   ElapsedEventArgs   e)   
              {   
                      Application.Lock();   
                      Application["a"]   =   "hehe:"   +   DateTime.Now.ToString("mm:ss");   
                      Application.UnLock();   
              }
      

  6.   

    哦,我刚接触.net不太懂,楼上能把WEB中使用定时器说得更详细些吗??
    比如怎么能看到定时的结果,即怎么进行测试呢??
      

  7.   

    webform只能在客户端使用定时器,客户端访问完毕后是与服务器端断开的,服务器不能主动向客户端发送内容的
      

  8.   

    楼主试过Ajax提供的Timer服务器控件吗?
      

  9.   

    最最简单的一个例子就是:
    vs05:
    建一个Ajax Enabled Web Site,这时已经有个ScriptManager在页面里了,拖一个UpdatePanel,然后拖一个Timer放到UpdatePanel里,设置Interval属性为1000(1秒),再放一个Label1,双击Timer,在Timer1_Tick处理方法里:
    Label1.Text = DateTime.Now.ToString();
      

  10.   

    使用javascript来实现客户端的定时事件。连接数据库、修改TextBox的值还是要放到服务端代码中。可以考虑,每次到达定时就刷新一次页面。再将刷新文本的方法放到page_load中应该就可以了。其实还是那句话,b/s下一定不要总想着c/s下的实现方式。
    ps:定时实现参考:http://hi.baidu.com/tryboy27/blog/item/6c413bef3e03b0ebcf1b3e7e.html
      

  11.   

    使用javascript来实现客户端的定时事件。连接数据库、修改TextBox的值还是要放到服务端代码中。可以考虑,每次到达定时就刷新一次页面。再将刷新文本的方法放到page_load中应该就可以了。其实还是那句话,b/s下一定不要总想着c/s下的实现方式。
    ps:定时实现参考:http://hi.baidu.com/tryboy27/blog/item/6c413bef3e03b0ebcf1b3e7e.html
      

  12.   

    使用javascript来实现客户端的定时事件。连接数据库、修改TextBox的值还是要放到服务端代码中。可以考虑,每次到达定时就刷新一次页面。再将刷新文本的方法放到page_load中应该就可以了。其实还是那句话,b/s下一定不要总想着c/s下的实现方式。
    ps:定时实现参考:http://hi.baidu.com/tryboy27/blog/item/6c413bef3e03b0ebcf1b3e7e.html
      

  13.   

    好像还是不行啊~~问题好像是这个问题,不过不知道该怎么解决啊~
    实在不行我就考虑用Socket通信来解决了~~将服务器端改变的值传回给客户端~~不知道这样行不行~~
    Socket也不会啊~~晕啊~~开始学习Socket~~看看能不能行吧~~
    先谢谢大家了