473,654 Members | 3,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ParseE xact(TextBox.te xt, '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 2288
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*****@discus sions.microsoft .com> wrote in message
news:B8******** *************** ***********@mic rosoft.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.ParseE xact(TextBox.te xt, '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*****@discus sions.microsoft .com> wrote in message
news:B8******** *************** ***********@mic rosoft.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.ParseE xact(TextBox.te xt, '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
1909
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 System.Globalization.CultureInfo("de-DE") string name= culture.Name; // Produces "de-DE" string s = (3.5).ToString(culture); // produces "3.5". Should produce "3,5" string t = (new System.DateTime()).ToString("T",culture); // produces "2/16/2004". Should produce "16.2.2004" ...
3
1428
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 is the real Lunar Calendar and not just some sort of customization of the Gregorian Calendar. If this is so, I would like to go a head and test it a bit, so could someone tell me how to invoke, for example, the GetDayofMonth method, i.e....
2
1272
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 write this code for trasformation but not it works : Dim DtInfo As DateTimeFormatInfo = New CultureInfo("it-IT", False).DateTimeFormat
2
1832
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 use clicks on the calendars, the proper date gets filled in the text boxes below the calendars. I noticed that if you click on the date correspinding to the current date, the textboxes do not get filled or changed. Is this a bug? If not how can...
4
3923
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 viewstate. I had created 4 methods to Add/Remove my special dates in viewstate. Up to here all seems perfect, but how do I used it in prerender event for my new calendar control.
1
3631
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 FormView, and made this Calender control's SelectedDate: SelectedDate='<%# Bind('helloDate') %>'
8
6137
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); tbxDisplayResult.Text = DateTime.Parse(tbxInputArea.Text, culture).ToString("yyyy MMMMMMMMMM dd");
8
15044
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 independent from the culture of the current user, I use decimal.Parse(volume, new System.Globalization.CultureInfo("fr-FR", true)); but this function fails with : Exception : Input string was not in a correct format.
2
3263
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 calendar controls on a page and attempting to update them with holiday and eventually vacation information. The methods SetCalendarValues() and GetCurrentMonthData() work as expected, however, I'm not quite sure how to incorporate the method...
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.