关于DateTime的自定义文本框控件 [英] Regarding Custom Text box Control For DateTime

查看:95
本文介绍了关于DateTime的自定义文本框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我在ASP.Net中有一个项目,其中包含大约1200个表单.印度客户和美国客户都在使用它.

我已经按照所有印第安语格式写了所有表格的所有代码,并以dd/MM/yyyy表示了日期格式,但美国人却以MM/dd/YYYY表示了日期.客户要求他们必须只能以其格式输入日期,即MM/dd/YYYY,其中有相同的文本框.

但是,由于我以dd/MM/yyyy格式编写了所有代码,并且所有计算部分都以相同格式完成,所以我将无法完全更改代码.

因此,现在我需要一些自定义文本框控件来验证美国客户,同时用MM/dd/YYYY格式的日期填充文本框;但计算部分仍采用dd/MM/yyyy格式.

有没有其他解决方案,请告诉我.

谢谢

Varun Sareen

Dear Friends,

I have a project in ASP.Net which contains around 1200 forms. It is being used by both the indian clients and the US clients.

I have written all the code for all the forms and taken the date format in dd/MM/yyyy, according to indian format but as the americans write date in MM/dd/YYYY; the clients are requiring that they must be able to enter the date only in their format i.e., MM/dd/YYYY where there are textboxes for the same.

But as i have written all the code in dd/MM/yyyy format and all the computing part is done in the same format only it will be impossible for me to change alogether the code.

So, now i am requiring some custom textbox control which validates the US clients, while filling the text box with date in format MM/dd/YYYY; but still does the computing part in the format dd/MM/yyyy.

Is there any alternative solution to this then kindly let me know.

Thanks

Varun Sareen

推荐答案

只需执行以下操作

Just do as follows

DateTime startDate = new DateTime(2010, 01, 01);
string customFormat = "MM/dd/yyyy";

txtStartDate.Text = startDate.ToString(customFormat);



会起作用的.
注意:检查格式应与"MM/dd/yyyy"完全相同.



It will work.
Note: Check format should be exactly same as "MM/dd/yyyy".


这篇关于关于DateTime的自定义文本框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆