ArmorCode
ArmorCode

Reputation: 749

How do I Display date on Aspx page?

I am using asp.net webforms for the first time and am trying to display the current date in the following form: Friday, July 13

<h3>Suggested reading for <% DateTime.Now.ToString(); %></h3>

However, this only displays

Suggested reading for

on my page.

I don't know if this helps, but here is some surrounding code:

<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Fake_Coupon_Site.Account.Register" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <hgroup class="title">
        <h1><%: Title %>.</h1>
        <h2>Use the form below to create a new account.</h2>
        <h3>Suggested reading for <% DateTime.Now.ToString(); %></h3>
    </hgroup>

Upvotes: 5

Views: 22267

Answers (1)

Brent Mannering
Brent Mannering

Reputation: 2316

Try

<h3>Suggested reading for <%= DateTime.Now.ToString("dddd, MMMM dd") %></h3>

Upvotes: 11

Related Questions