Pages

Tuesday, 21 February 2012

Show Current Date and Time in ASP.NET

            Developers generally like to include some of their own custom JavaScript function in their ASP.NET pages.You have a couple of ways to do this.The first is to apply JavaScript directly to the controls on your ASP.NET pages.For example,look at a simple Label control that displays current Date and Time on Page Load.
VB 
     Protected Sub Page_Load(ByVal sender As object,ByVal e As System.EventArgs)
           Label1.Text = DateTime.Now.ToString( ) ;
     End Sub
C#
     protected void Page_Load(object sender,EventArgs e)
     {
            Label1.Text = DateTime.Now.ToString( ) ;
     }
              This little bit of code displays the current date and time on the page of the end user.

No comments:

Post a Comment