我有一个类似这样的日历:
视图
<td>
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="DateChange">
</asp:Calendar>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
.Cs 文件
protected void Page_Load(object sender, EventArgs e)
{
TextBox2.Text = DateTime.Today.ToShortDateString()+'.';
}
protected void DateChange(object sender, EventArgs e)
{
TextBox2.Text = Calendar1.SelectedDate.ToShortDateString() + '.';
}
它显示的日期格式是"MM/dd/yyyy"
,但我想把它显示为"dd/MM/yyyy"
,我尝试将DateTime.Today.ToShortDateString()+'.'
更改为DateTime.Today.ToString("dd/MM/yyyy")+'.'
但是我得到了错误:
Error 3 No overload for method 'ToShortDateString' takes 1 arguments
我该怎么做才能解决这个问题?
"d", "D", "f", "F", "g", "G", "m", "o", "r", "s", "t", "T", "u", "U", "Y"
。 - Sinjai/
(对于“DateSeparator”)和:
(对于“TimeSeparator”)指定符在自定义日期和时间格式中有“特殊”的含义,即“将当前区域设置或提供的区域设置的日期或时间分隔符替换为我”。如果您没有使用任何区域设置这些指定符,则它们将被替换为“CurrentCulture”的日期和/或时间分隔符,这可能与不同文化的/
或:
不同。 - Soner Gönül/
和:
字符具有特殊含义,其"表示"取决于您使用的文化设置。 - Soner Gönül