I have screen in c# asp.net webapplication, where i add news on particular dates.And can edit those dates also.It workes in my local sytem.But shows datetime error when it was running in iis 7 server(Used sql database).And i knew that the short date and long date format in server was different from local system.So i changed date format in local system same as in iis.But still it is working properly.
问问题
670 次
1 回答
1
不要猜测文化设置,而是在取消Thread.CurrentCulture属性后从数据库读取/恢复之前编写设置您需要的代码。与下面的代码类似(还需要使用 CurrentUICulture,选择您需要的文化并将代码围绕设置/恢复到try
/finally
用于真实代码)
var oldCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
// read from DB
...
Thread.CurrentThread.CurrentCulture = oldCulture;
于 2012-11-19T05:41:04.623 回答