How to get current date in ASP.NET

I’m using the folloing function to get current date


<script language="VB" runat="server">
public function stl() As Date
dim d as date
d = Date()
	return d
end function
</script>

But I get the following error


Compiler Error Message: BC30108: 'Date' is a type, and so is not a valid expression. Expected a variable, constant, or procedure.

Source Error:

Line 11: public function stl() As Date
Line 12: dim d as date
Line 13: d = Date()
Line 14: 	return d
Line 15: end function


Source File: C:\\WebServers\\Gazeta\\1.aspx    Line: 13

Where am I wrong?
Thank you

Try:


...
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
   showDate.text = DateTime.Now
end sub
</script>
</head>
<body>
<asp:Label id="showDate" runat="Server" DataFormatString="{0:d}" />
...

:slight_smile: