SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Russia
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to get current date in ASP.NET

    I'm using the folloing function to get current date
    Code:
    <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

    Code:
    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
    Regards,
    Alexander Saprykin
    http://www16.brinkster.com/saprykin

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    Code:
    ...
    <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}" />
    ...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •