473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

cultureInfo calendar DateTime problem

Hi all,

In a user control, the user can put the cultureinfo to his preference,
choosing between "nl-BE","fr-BE", and "en-US". this way all calendar and
datetime properties are set in the right structure.
In a webform I have two textboxes which are filled in by a CalendarPicker in
a Pop-up window, a StartDate and an EndDate.

Works fine.

But on Form.submit, the two textbox.Text are converted by this method
DateTime.ParseExact(TextBox.text, 'ddd,dd MMM yyyy', format)
where format is CurrentCulture.CultureInfo

This works fine if the user does not change his language preferences (and
thus the cultureInfo).

But he wants his application to work in english or french, he gets a
'Datetime is not valid' parser error

Anyone ?
Nov 19 '05 #1
2 2275
You're getting the error because ParseExact is trying to deal with a
hardcoded date format that make no sense for some cultures. Imagine what
happens when the user enters 15 for the day but it is being used in the code
as the month value.

The whole page and its controls need to use the same culture info, including
the UI culture.

You might want to try it without ParseExact to see if the datetime will be
accepted for the selected culture.
"Boonaap" <Bo*****@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Hi all,

In a user control, the user can put the cultureinfo to his preference,
choosing between "nl-BE","fr-BE", and "en-US". this way all calendar and
datetime properties are set in the right structure.
In a webform I have two textboxes which are filled in by a CalendarPicker
in
a Pop-up window, a StartDate and an EndDate.

Works fine.

But on Form.submit, the two textbox.Text are converted by this method
DateTime.ParseExact(TextBox.text, 'ddd,dd MMM yyyy', format)
where format is CurrentCulture.CultureInfo

This works fine if the user does not change his language preferences (and
thus the cultureInfo).

But he wants his application to work in english or french, he gets a
'Datetime is not valid' parser error

Anyone ?


Nov 19 '05 #2
the user cannot manually add the date to the textbox, it goes with a pop-up
window, a calendar tool and the value is formatted to the same string as the
one parseExact uses

"Ken Cox [Microsoft MVP]" wrote:
You're getting the error because ParseExact is trying to deal with a
hardcoded date format that make no sense for some cultures. Imagine what
happens when the user enters 15 for the day but it is being used in the code
as the month value.

The whole page and its controls need to use the same culture info, including
the UI culture.

You might want to try it without ParseExact to see if the datetime will be
accepted for the selected culture.
"Boonaap" <Bo*****@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Hi all,

In a user control, the user can put the cultureinfo to his preference,
choosing between "nl-BE","fr-BE", and "en-US". this way all calendar and
datetime properties are set in the right structure.
In a webform I have two textboxes which are filled in by a CalendarPicker
in
a Pop-up window, a StartDate and an EndDate.

Works fine.

But on Form.submit, the two textbox.Text are converted by this method
DateTime.ParseExact(TextBox.text, 'ddd,dd MMM yyyy', format)
where format is CurrentCulture.CultureInfo

This works fine if the user does not change his language preferences (and
thus the cultureInfo).

But he wants his application to work in english or french, he gets a
'Datetime is not valid' parser error

Anyone ?


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rerdavies | last post by:
OS: WIndows Server 2003. Currently logged in user is running with German(German) regional settings. Code fragment: System.Globalization.CultureInfo culture = new...
3
by: | last post by:
Hi all, I am new to .net so I am still unsure how to do thing, but I have discovered a class called HebrwCalendar and I am so excited that I must ask if someone can help me. First, I assume this...
2
by: Giorgio | last post by:
I would to format the date in Italian ...(dd/mm/yyyy) I have set an another language in International setting(for test i have set Lettonia) The format date for this nation is yyyy.mm.dd ... I...
2
by: Mariano Padilla | last post by:
The calendar control only has the event of SelectionChanged to detect if the user clicks on the calendar. I have 2 calendars on a form, one for arrival date one for departure date. Every time a...
4
by: rushikesh.joshi | last post by:
Hi All, I want to create custom control by using Web.UI.WebControls.Calendar, in which I want to set few days with different color. I had created two property to set the color and storing in...
1
by: Loading name... | last post by:
Hey asp.net 2.0 I have a FormView on my webpage. This FormView's datasource is a SqlDataSource object. This SqlDataSource returns 1 datetime field. So I've added a Calendar control to the...
8
by: Rico | last post by:
Hello Everyone, I observed something strange in some quick testing code: void Button1Click(object sender, System.EventArgs e) { CultureInfo culture = new CultureInfo("th-TH", false); ...
8
by: =?Utf-8?B?T2xpdmllciBHSUw=?= | last post by:
Hello, I try to convert a volume stored as a string value in an XML file into a Decimal object. The volume is stored with comma as decimal separator ("210,12") according to french habits. To be...
2
by: Tigers07 | last post by:
I've been banging my head on a problem all day and am looking for some advice. I'm fairly new to asp.net/vb.net so I appologize if this seems a bit elementary. Anyway, what I'm doing is displaying 12...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.