|
-
Jan 28th, 2004, 05:50 PM
#1
Thread Starter
Fanatic Member
Date - very simple.
I am trying to learn c#, and have a VERY simple question. How do you display the current date inside of a td tag, also how do you display the current time inside a td tag?
Thanks.
-
Jan 28th, 2004, 11:22 PM
#2
Hyperactive Member
You can get the current datetime with DateTime.Now, and the ToString() method accepts many different format patterns to display date and time pretty much as many ways as you can think of:
Code:
<table>
<tr>
<td><%= DateTime.Now.ToString("HH:mm MM/dd/yyyy") %></td>
</tr>
</table>
-
Jan 29th, 2004, 10:55 AM
#3
Thread Starter
Fanatic Member
It worked, although I am confused. If this is c#, where is the ;?
-
Jan 29th, 2004, 08:27 PM
#4
Hyperactive Member
It's just the way those tags work. You're not sticking a line of code in there, it's an expression that must evaluate to a value. This line fails
PHP Code:
<%= Response.Write("Hello World") %>
because Response.Write("Hello World") does not evaluate to a value. This line also fails:
PHP Code:
<% Response.Write("Hello World") %>
because a semi-colon is missing(assuming you declared C# to be the language for the page). This line works
PHP Code:
<% Response.Write("Hello World"); %>
Not sure if this made it clearer or cloudier for ya, maybe someone else has a better explanation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|