簡體   English   中英

如何在Aspx頁面上顯示日期?

[英]How do I Display date on Aspx page?

我是第一次使用asp.net webforms,我試圖以下面的形式顯示當前日期: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>

嘗試

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM