asp.net中单击一个按钮A开始计时,单击另一个按钮B停止计时,如何截取时间中间的这段时间,求各位高手帮忙!谢谢了

解决方案 »

  1.   

    用两个DateTime.Now不行吗,然后写个方法把两个时间想减
      

  2.   

    protected void Button1_Click(object sender, EventArgs e)
    {
    Session["time"] = DateTime.Now;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    if (Session["time"] != null)
    {
    TimeSpan span1=(DateTime.Now - Convert.ToDateTime(Session["time"]));
    Response.Write(span1.ToString());
    }
    }
      

  3.   

    protected DateTime dt = DateTime.Now;
    点击按钮timer执行
    停止timer时
    TimeSpan ts = DateTime.Now - dt;
       
      

  4.   

    两个日期比较
    http://topic.csdn.net/u/20110108/14/e9d2755b-ff3a-43fd-84ba-9d11c56f722d.html你单击A时的当前时间保存在全局变量中,然后单击B获取时间,比较时间
      

  5.   

    这个更好,精确到秒为止:
    protected void Button1_Click(object sender, EventArgs e)
    {
    Session["time"] = DateTime.Now;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    if (Session["time"] != null)
    {
    TimeSpan span1=(DateTime.Now - Convert.ToDateTime(Session["time"]));
    Response.Write(Convert.ToDateTime(span1.ToString()).ToString("HH:mm:ss"));
    }
    }
      

  6.   

    这样是可以的 你声明2个datetime 也可以实现