【问题标题】:How do I Display date on Aspx page?如何在 Aspx 页面上显示日期?
【发布时间】:2014-03-07 04:28:41
【问题描述】:

我是第一次使用 asp.net 网络表单,并试图以以下形式显示当前日期:7 月 13 日,星期五

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

但是,这只显示

Suggested reading for

在我的页面上。

我不知道这是否有帮助,但这里有一些周边代码:

<%@ 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>

【问题讨论】:

    标签: c# asp.net datetime webforms


    【解决方案1】:

    试试

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

    【讨论】:

    • 只是不同类型的代码块,''和写''是一样的,这里有一些有关不同代码块及其作用的更多信息:support.microsoft.com/kb/976112
    • 您可能还想将区域性添加到 ToString 方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 2015-05-13
    相关资源
    最近更新 更多