US vs UK datetime/string format failing on certain machines. Ideas

G

Guest

I'm having a problem with dates.
(No not the sort that you have at christmas)

I have a webform with a text box and a calendar control.
You can either
- enter a date manually (we are talking uk style here dd/mm/yyyy) in the
textbox
- click a date on the calendar which puts the date value in the textbox (uk
style)

pointing a browser at my machine this works fine
pointing at the UAT and production machines it falls in a heap with the
error shown below

I've asked our admin to check and he says everything is configured to be uk
where possible

This is for an intranet app so i'm not bothered about time zones and all
that crap.
i've seen a bunch of postings where people are using
datetime.parse(xx,formatprovider) with all sorts of bits and pieces
and some of the formatting things are crazy
5 or 6 lines of code just to format something from a text box

i thought asp.net was supposed to make you more productive with fewer lines
of code!

why am i getting the error?
is there any file on the servers in question i can change to make it work?

also

all of the other date values on the screen (when using the other servers)
are shown using US date format

can anyone shed any light on this?

thanks!

ERROR START-----

Server Error in '/inDus' Application.
--------------------------------------------------------------------------------

String was not recognized as a valid DateTime.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid DateTime.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[FormatException: String was not recognized as a valid DateTime.]
inDus.Data.Release.CreateNewRelease(String Description, String
ReleaseDate, Int32 ProjectID)
inDus.Releases.AddRelease.CmdCreateRelease_Click(Object sender, EventArgs
e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
 
D

Daniel Fisher\(lennybacon\)

I have a webform with a text box
- enter a date manually (we are talking uk style here dd/mm/yyyy) in the
Does this work on all machines?
- click a date on the calendar ... (uk style)
Is the problem that putting the date converts it to mm/dd/yyyy ?
I've asked our admin to check and he says everything is configured to be
uk
where possible
Hey it*s your Job ;-)
i've seen a bunch of postings where people are using
datetime.parse(xx,formatprovider) with all sorts of bits and pieces
If you know what your users enter (Intranet) you shouldn't need that.
i thought asp.net was supposed to make you more productive with fewer
lines
of code!
why am i getting the error?
is there any file on the servers in question i can change to make it work?

also

all of the other date values on the screen (when using the other servers)
are shown using US date format

can anyone shed any light on this?

What is you Culture and UICulture in the web.config - if it's not set it'll
be en-US

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

you can set the culture by code to

System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
System.Threading.Thread.CurrentThread.CurrentUICulture =
System.Threading.Thread.CurrentThread.CurrentCulture;
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top