VK LABELS

Sunday, 16 March 2014

Create a Web Page for show current date and Time using VB.Net

Create a Web Page for show the Current Date and Time:
  • Design Web Page Using Text Box, Label Box, and Button.
  • Use Script manager, and Timer.
  • Use the below code to show current date and time in vb.net web application.

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = Format(DateTime.Now, "dd/MM/yyyy")
        TextBox2.Text = Format(Now, "Long Time")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Timer1.Enabled = True
        Timer1.Interval = 1000
    End Sub

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label5.Text = Format(DateTime.Now, "dd/MM/yyyy")
        Label4.Text = Format(Now, "Long Time")
    End Sub
End Class

No comments:

Post a Comment