NET1.1: RangeValidator doesn't work with Hungarian DateTime

A

Axel Dahmen

Hi,

I'm working in a team developing an international website. When I set the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07. 11.' of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
F

Frank Lehmann

Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank
 
A

Axel Dahmen

Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Frank Lehmann said:
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank

Hi,

I'm working in a team developing an international website. When I set the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07. 11.' of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
F

Frank Lehmann

Hi Axel,

I'm a bit speculating because I'm everything else but an expert in using
CultureInfo:
Could there be a connection with the Regional Settings in Control Panel
so that Windows itself isn't Hungarian and the Windows date format overrides
the CultureInfo?

Regards,
Frank

Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Frank Lehmann said:
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank

Hi,

I'm working in a team developing an international website. When I set the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07. 11.' of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
A

Axel Dahmen

Nope. Everything else's working fine in Hungarian, I'm afraid...



Frank Lehmann said:
Hi Axel,

I'm a bit speculating because I'm everything else but an expert in using
CultureInfo:
Could there be a connection with the Regional Settings in Control Panel
so that Windows itself isn't Hungarian and the Windows date format overrides
the CultureInfo?

Regards,
Frank

Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Frank Lehmann said:
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank


Hi,

I'm working in a team developing an international website. When I
set
the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator
doesn't
seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07.
11.'
of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
A

Axel Dahmen

So this topic remains unsolved.. desperately searching for thoughts -
anyone, please?



--------------------
 
F

Frank Lehmann

Hi Axel,

Me once again. I've tested the following code in VB2003 .NET 1.1:

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")

RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString

without any errors.

RangeValidator1.MaximumValue then is '2006. 07. 11.'

There is one question I have about your code:
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****

I can't figure out what value you have for value.ToShortDateString().
Can it be converted to a valid date string?
Would
set {rngDate.MaximumValue=DateTime.Now.ToShortDateString();}
run without error?

Regards,
Frank



Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Frank Lehmann said:
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank

Hi,

I'm working in a team developing an international website. When I set the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07. 11.' of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
A

Axel Dahmen

Hi Frank,

where are you setting this value? I'm setting it at Page_Init()

Value, in fact, is coming from DateTime.Now. I've set up a second page
setting DateTime.Now.ToShortDateString() - same error.

From the error message in my first posting one can see that the value
provided is correct. The stack trace shows that the error is somewhere deep
inside the RangeValidator control.

PLEEEASEE HEEEELP - anyone...

TIA,
Axel

-----------------------
Frank Lehmann said:
Hi Axel,

Me once again. I've tested the following code in VB2003 .NET 1.1:

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")

RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString

without any errors.

RangeValidator1.MaximumValue then is '2006. 07. 11.'

There is one question I have about your code:
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****

I can't figure out what value you have for value.ToShortDateString().
Can it be converted to a valid date string?
Would
set {rngDate.MaximumValue=DateTime.Now.ToShortDateString();}
run without error?

Regards,
Frank



Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Frank Lehmann said:
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank


Hi,

I'm working in a team developing an international website. When I
set
the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator
doesn't
seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate' cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07.
11.'
of
the MaximumValue property of 'rngDate' cannot be converted to type 'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
A

Axel Dahmen

One more note: Perhaps it's important to know that we're using American
Windows 2000 clients and servers. Perhaps they're behaving differently from
German versions?

TIA,
Axel Dahmen
 
F

Frank Lehmann

Hi Axel,

I played a bit with CultureInfo this morning. IMO it's clearly a bug in
RangeValidator.

You can put the code in Page_Init or Page_Load, it won't work.

Const min_val As String = "2006. 01. 01."
Const max_val As String = "2006. 07. 13."

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")
RangeValidator1.Type = ValidationDataType.Date

If RangeValidator1.CanConvert(min_val, ValidationDataType.Date) Then
RangeValidator1.MinimumValue = min_val
End If
If RangeValidator1.CanConvert(max_val, ValidationDataType.Date) Then
RangeValidator1.MaximumValue = max_val
End If

CanConvert is false and shows that such a date format cannot be converted for
Hungarian culture.
The same is true for lv-LV and lt-LT. These are the three ASP.NET cultures using
yyyy.MM.dd or yyyy. MM. dd. as ShortDateString.

If you set RangeValidator1.Type = ValidationDataType.String, then it works.
That was my solution "without error" yesterday, but it doesn't meet the necessity
to recognize input date formats like yyyy. m. d. as valid, because they are
compared as strings, not dates.

A date format convertible for "hu-HU" is yyyy-MM-dd.
Interestingly and unfortunately, although the CultureInfo("hu-HU") has yyyy. MM. dd.
as ShortDateFormat, the input date must then also be [yy]yy-[M]M-[d]d,
in the format of the min and max values!
Nevertheless, perhaps this might be a workaround for you.

Regards,
Frank
Hi Frank,

where are you setting this value? I'm setting it at Page_Init()

Value, in fact, is coming from DateTime.Now. I've set up a second page
setting DateTime.Now.ToShortDateString() - same error.

From the error message in my first posting one can see that the value
provided is correct. The stack trace shows that the error is somewhere deep
inside the RangeValidator control.

PLEEEASEE HEEEELP - anyone...

TIA,
Axel

-----------------------
Frank Lehmann said:
Hi Axel,

Me once again. I've tested the following code in VB2003 .NET 1.1:

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")

RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString

without any errors.

RangeValidator1.MaximumValue then is '2006. 07. 11.'

There is one question I have about your code:
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****

I can't figure out what value you have for value.ToShortDateString().
Can it be converted to a valid date string?
Would
set {rngDate.MaximumValue=DateTime.Now.ToShortDateString();}
run without error?

Regards,
Frank



Well, I guess so,

the value is coming from .NET so it should be alright. It works for all the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank


Hi,

I'm working in a team developing an international website. When I set
the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't
seem
to be able to parse a TextBox's date value (Exception message see below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate'
cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006. 07. 11.'
of
the MaximumValue property of 'rngDate' cannot be converted to type
'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the
MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 
A

Axel Dahmen

Hi Frank,

thanks a lot for trying to help! A colleague of mine just contacted MS.
There's a bug in .NET 1.1 and here's how to obtain a hotfix:
http://support.microsoft.com/kb/834330

TIA and best wishes,
Axel Dahmen



------------------
Frank Lehmann said:
Hi Axel,

I played a bit with CultureInfo this morning. IMO it's clearly a bug in
RangeValidator.

You can put the code in Page_Init or Page_Load, it won't work.

Const min_val As String = "2006. 01. 01."
Const max_val As String = "2006. 07. 13."

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")
RangeValidator1.Type = ValidationDataType.Date

If RangeValidator1.CanConvert(min_val, ValidationDataType.Date) Then
RangeValidator1.MinimumValue = min_val
End If
If RangeValidator1.CanConvert(max_val, ValidationDataType.Date) Then
RangeValidator1.MaximumValue = max_val
End If

CanConvert is false and shows that such a date format cannot be converted for
Hungarian culture.
The same is true for lv-LV and lt-LT. These are the three ASP.NET cultures using
yyyy.MM.dd or yyyy. MM. dd. as ShortDateString.

If you set RangeValidator1.Type = ValidationDataType.String, then it works.
That was my solution "without error" yesterday, but it doesn't meet the necessity
to recognize input date formats like yyyy. m. d. as valid, because they are
compared as strings, not dates.

A date format convertible for "hu-HU" is yyyy-MM-dd.
Interestingly and unfortunately, although the CultureInfo("hu-HU") has yyyy. MM. dd.
as ShortDateFormat, the input date must then also be [yy]yy-[M]M-[d]d,
in the format of the min and max values!
Nevertheless, perhaps this might be a workaround for you.

Regards,
Frank
Hi Frank,

where are you setting this value? I'm setting it at Page_Init()

Value, in fact, is coming from DateTime.Now. I've set up a second page
setting DateTime.Now.ToShortDateString() - same error.

From the error message in my first posting one can see that the value
provided is correct. The stack trace shows that the error is somewhere deep
inside the RangeValidator control.

PLEEEASEE HEEEELP - anyone...

TIA,
Axel

-----------------------
Frank Lehmann said:
Hi Axel,

Me once again. I've tested the following code in VB2003 .NET 1.1:

Thread.CurrentThread.CurrentCulture() = New CultureInfo("hu-HU")

RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString

without any errors.

RangeValidator1.MaximumValue then is '2006. 07. 11.'

There is one question I have about your code:

get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****

I can't figure out what value you have for value.ToShortDateString().
Can it be converted to a valid date string?
Would
set {rngDate.MaximumValue=DateTime.Now.ToShortDateString();}
run without error?

Regards,
Frank




Well, I guess so,

the value is coming from .NET so it should be alright. It works for
all
the
other languages we've implemented so far (e.g.: de, en, fr, nl, cz)...

This is the code:

public DateTime MaximumDate
{
get {return Convert.ToDateTime(rngDate.MaximumValue);}
set {rngDate.MaximumValue=value.ToShortDateString();} // <--- *****
}

TIA,
Axel



----------------
Hi Axel,

Are you sure your date of 2006.07.11 is allowed to have
spaces before month and day?

Regards,
Frank


Hi,

I'm working in a team developing an international website. When
I
set
the
page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't
seem
to be able to parse a TextBox's date value (Exception message
see
below)
correctly.

The TextBox's value is coming from the DateTime.Now.ToShortDateString()
function, so it's an original .NET value.

Can someone please help me out on this? I need to be able to get this
application running until end of the week.

TIA,
Axel Dahmen

------------------------------
The value '2006. 07. 11.' of the MaximumValue property of 'rngDate'
cannot
be converted to type 'Date'.

Exception Details: System.Web.HttpException: The value '2006.
07.
11.'
of
the MaximumValue property of 'rngDate' cannot be converted to type
'Date'.

Stack Trace:

[HttpException (0x80004005): The value '2006. 07. 11.' of the
MaximumValue
property of 'rngDate' cannot be converted to type 'Date'.]
System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()
System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top