ASP.net 区域性问题语言选项 (win2k3)

发布于 2024-11-02 17:18:09 字数 933 浏览 2 评论 0原文

我有一个 Asp.net 表单的文本框。有一个简单的 javascript 可以分隔 TextBox 中的每三个数字。当您在文本框中输入数据时,它工作正常。我使用逗号 , 来分隔数字,并使用点 . 作为浮点字符。

正如我所说,当我在文本框中输入数据时,一切正常。但是当发生回发并且保存的数据返回到客户端时,每个 .(s) 都已被删除(例如 2.3 保存为 23< /code> 和 TextBox 中的数字由 . 分隔,而不是 ,

此问题仅发生在特定服务器(windows server 2003 sp1)中并且工作正常在其他 Windows Server 2003 中(SP1)!我第一次遇到这个问题!

但我认为问题是因为当我将区域和语言选项更改为该服务器时。设置:

小数符号 -> .

数字分组符号 ->

没有任何变化。

当我检查时 自定义设置后的以下项目:

全部应用当前用户帐户和默认用户配置文件的设置 ->检查

当我重新启动服务器时,它会从域中跳出,需要重新加入域控制器!当然,一切都不再改变!

你有这个问题吗?请任何解决方案!

我无法在这里发布代码,因为代码太复杂,我确信问题不是因为代码,因为除非指定的服务器,否则它在任何地方都可以工作。

编辑

还为网络服务用户设置区域和语言选项可能有助于解决问题。有人知道我该怎么做吗?

I have a TextBox in an Asp.net form. there is a simple javascript witch separates each three digits in TextBox. it works fine when you enter data in TextBox. I used coma , for separating digits and used dot . as floating point character.

as I said every thing works fine when I am entering data in TextBox. but when the post-back occurs and saved data returns to client, every .(s) has been removed (for example 2.3 saved as 23 and digits in TextBox are separated by . instead of ,.

this problem occurs just in a specific server (windows server 2003 sp1) and works fine in other windows server 2003 (SP1)! I am experiencing this problem for first time!

But I think the problem is because of specific Regional & Language Options in the server. This server is joined to a domain controller. when I change the regional and language options to this set:

Decimal Symbol -> .

Digit Grouping Symbol -> ,

nothing changes.

when I check the following item after customizing settings :

Apply All Settings to the current user account and to the default user profile -> checked

when I restart the Server, It jumps out from domain and need to be re-joined to domain controller! and of-course nothing changes again!

Do you had this problem? any solution please!

I can not post code here, because the code is too complex and I am sure problem is not because of code because it is working every where unless the specified server.

EDIT

Also setting regional and language options for network service user may help to solve the problem. any body knows how can I do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

極樂鬼 2024-11-09 17:18:10

您是否尝试过在 web.config 中使用全球化标签?这可以防止您在多个服务器配置不同(即不同的语言包)时遇到麻烦。

<configuration>
   <system.web>
      <globalization 
         culture="en-US"
         uiCulture="en-US" />
   </system.web>
</configuration>

Have you tried using the globalization tag in your web.config? This prevents you from running into trouble when multiple servers are configured differently (ie. different languagepacks).

<configuration>
   <system.web>
      <globalization 
         culture="en-US"
         uiCulture="en-US" />
   </system.web>
</configuration>
残花月 2024-11-09 17:18:10

在解决类似的问题很长时间后,我在一些线索的帮助下做了以下工作(顺便说一句,StackOverFlow 也发现了,StackOverFlow 很摇滚......)

我做的第一件事就是转储服务器的内容实际上的想法(Page_Load):

var dtInfo = System.Globalization.DateTimeFormatInfo.CurrentInfo;
DisplayDebugInfo(String.Format(
    "Culture({0}/{1}), DateFormat(SD:{2},DS:{3})",
    System.Globalization.CultureInfo.CurrentCulture.Name,
    System.Globalization.CultureInfo.CurrentUICulture.Name,
    dtInfo.ShortDatePattern, dtInfo.DateSeparator));

同样在Windows 2003上,我尝试通过常规控制面板修复区域设置,但没有成功。

我还尝试在 web.config 中设置全球化设置,如其他解决方案中所述,但效果甚微。

似乎一旦你开始搞乱区域设置,你很快就会陷入混乱的地步。我决定避免弄乱注册表并寻求代码解决方案,因为这样我就不必担心我的代码何时发布到生产环境。

我将以下代码添加到我的页面的基类中,以便它可以在任何地方修复它。您也可以将其放在 Page_Load 中。

using System.Globalization;
using System.Threading;

// Fix the cultural settings...
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
culture.DateTimeFormat.DateSeparator = "/";
Thread.CurrentThread.CurrentCulture = culture;

问题解决了。无论如何对我来说。

After goofing around with a similar problem for WAY to long I did the following with the help of a number of clues (also found on StackOverFlow, StackOverFlow rocks by the way...)

The first thing I did was dump out what the server was actually thinking (Page_Load):

var dtInfo = System.Globalization.DateTimeFormatInfo.CurrentInfo;
DisplayDebugInfo(String.Format(
    "Culture({0}/{1}), DateFormat(SD:{2},DS:{3})",
    System.Globalization.CultureInfo.CurrentCulture.Name,
    System.Globalization.CultureInfo.CurrentUICulture.Name,
    dtInfo.ShortDatePattern, dtInfo.DateSeparator));

Also on Windows 2003, I tried fixing the regional setting via the regular control panel but with no success.

I also tried setting the globalization settings in the web.config as mentioned in the other solution but with little effect.

It seems that once you start messing with the regional setting you can quickly get to the point where things are messed up. I decided to avoid messing with the registry and go for a code solution because then I would not have to worry when my code was released to production.

I added the following code to the base class for my page so that it would fix it everywhere. You could also place it in the Page_Load.

using System.Globalization;
using System.Threading;

// Fix the cultural settings...
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
culture.DateTimeFormat.DateSeparator = "/";
Thread.CurrentThread.CurrentCulture = culture;

Problem solved. For me anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文