如标题.

解决方案 »

  1.   

    在提交留言板时先触发一个JAVASCRIPT函数,在JAVASCRIPT函数里将当前时间赋给一个HIDDENTEXTBOX,然后在后台提取该值,即可得到用户端的时间
      

  2.   

    如果是获取用户提交留言的时间。用DateTime.Now就可以了
      

  3.   

    尝试了一下没有头文件 using System.?
    应该要添写JS语句吧?
    怎么JS添加?
      

  4.   

    <INPUT id="Text1"  type="hidden" name="Text1" runat="server">
    <asp:button id="Button1" runat="server" Text="Button"></asp:button>
    <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
    ***************************************************************
    if(!Page.IsPostBack)
    {
                    this.Button1.Attributes.Add("onclick","document.getElementById('Text1').value = new Date();return true;");
     }
    private void Button1_Click(object sender, System.EventArgs e)
    {
         this.TextBox2.Text = this.Text1.Value;//这里就可以得到客户端浏览器当前的时间了
    }
      

  5.   

    <<用户留言时,怎么能获得用户的系统时间.并返回到服务器追加到留言里?>> 
    但我还有一个问题不明白,为什么<INPUT id="Text1" type="hidden" name="Text1" runat="server">其中的runat="server"要在server运行
    我个人认为应该是在客户端运行才对.
    怎么在server运行就能得到client的系统时间,不明白
    ------------------------------------------------answer:
    关键在这里:this.Button1.Attributes.Add("onclick","document.getElementById('Text1').value = new Date();return true;");
    这行代码虽然写在cs里,但实际上是给Button1的客户端的onclick事件添加了一段脚本,这段脚本是在浏览器运行的,他把浏览器能获取的当前时间填入到一个文本框,那么回传服务器的时候,文本框的内容回传到服务器