vb.net 设置 asp:TextBox 的日期格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19579986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:36:34  来源:igfitidea点击:

Set dateformat of asp:TextBox

asp.netvb.netdate

提问by spydon

I have been put on fixing a VB.net app and now I am trying to set the date format to something that makes sense like dd-MM-yyyy or yyyy-MM-dd, anything that doesn't have the dates in a weird american order really.

我一直在修复 VB.net 应用程序,现在我试图将日期格式设置为有意义的东西,例如 dd-MM-yyyy 或 yyyy-MM-dd,任何没有奇怪日期的东西美国秩序真的。

So I have this row in my aspx file:

所以我的 aspx 文件中有这一行:

<asp:TextBox ID="txtDateFrom" type="date" runat="server"></asp:TextBox>

I tried setting globalization:

我尝试设置全球化:

<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-AU" uiCulture="en-AU" />

in Web.config but it didn't make a difference, is there anyway I can force it to use a special date format in the TextBoxes? Right now it displays differently in chrome and firefox.

在 Web.config 中,但它没有任何区别,无论如何我可以强制它在 TextBox 中使用特殊的日期格式吗?现在它在 chrome 和 firefox 中的显示不同。

Chrome:

铬合金:

Chrome textbox

铬文本框

Firefox:

火狐:

Firefox textbox

火狐文本框

采纳答案by nyaray

Short answer derived from one of the commenters, for all you googlers showing up here.

来自一位评论者的简短回答,适用于所有出现在这里的谷歌员工。

While the date has to be transferred in the yyyy-mm-dd format, the presentation may be whatever the browser chooses. In this case chrome implements an un-desired presentation behaviour, for your case.

虽然日期必须以 yyyy-mm-dd 格式传输,但演示文稿可以是浏览器选择的任何内容。在这种情况下,chrome 为您的情况实现了不希望的演示行为。