Mega Code Archive

 
Categories / ASP.Net / Language Basics
 

Convert Current date to Short Date String and set to asp

<%@ Page Language="VB" %> <script runat="server">     Sub Button1_Click(sender As Object, e As EventArgs)       Dim myDate As Date       myDate = Now()       Label1.Text = myDate.ToLongTimeString()       Label2.Text = myDate.ToLongDateString()       Label3.Text = myDate.ToShortTimeString()       Label4.Text = myDate.ToShortDateString()     End Sub </script> <html> <head> </head> <body>     <form runat="server">         <p>             <asp:Label id="Label1" runat="server">Label</asp:Label>         </p>         <p>             <asp:Label id="Label2" runat="server">Label</asp:Label>         </p>         <p>             <asp:Label id="Label3" runat="server">Label</asp:Label>         </p>         <p>             <asp:Label id="Label4" runat="server">Label</asp:Label>         </p>         <p>             <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>         </p>     </form> </body> </html>