在一個文本框,我驗證0和1之間的數字我想系統接受,而不是0.5的值0.5asp.net RangeValidator控件,接受MinimumValue和MaximumValue用逗號,而不是點
CultureInfo before = System.Threading.Thread.CurrentThread.CurrentCulture;
try
{
System.Threading.Thread.CurrentThread.CurrentCulture =
new CultureInfo("de-DE");
var rngVald = new RangeValidator
{
ControlToValidate = IdOfMyTextBox,
MinimumValue = "0",
MaximumValue = "1"
Type = ValidationDataType.Double,
ErrorMessage = "<span class=\"error\">*value should be bet. 0 and 1</span>"
};
panel.Controls.Add(rngVald);
}
finally
{
System.Threading.Thread.CurrentThread.CurrentUICulture = before;
}
即使在德國,浮點數用逗號表示,但系統仍不接受0,5作爲有效數字。
你在哪裏改變了文化?你必須在'Page_Init'中做到最新 –
我正在做Page_Load – Kamran