Culture and date setttings - inconsistency between VWD browser and IE.

Last post 05-12-2008 11:32 AM by LockH. 6 replies.

Sort Posts:

  • Culture and date setttings - inconsistency between VWD browser and IE.

    03-25-2007, 2:42 PM
    • Loading...
    • LockH
    • Joined on 03-25-2007, 2:58 PM
    • Scotland, where whisky has no e.
    • Posts 544

    I am using VWD 2005 Express SP2 with C# and SQL 2005 Express on Windows XP Pro SP2.


    I have some years of experience, but only 2 months ASP.NET and VWD.

    This is quite a long post, but stick with me, I have already read the documentation and searched the web, searched the forums, tried several "solutions" that didn't work.

    I have a problem with British/UK/en-GB date formats.  Yes I know, there have been a lot of posts about that, and I have studied them.

    I want dates to display as dd/mm/yy but they default to mm/dd/yy, US style.

    In SQL studio, the dates display as dd/mm/yyyy, which is fine.

    In VWD - Database Explorer - Show Table Data - the dates display as dd/mm/yyyy, which is fine.

    When I use {0:d} format strings, the dates display as mm/dd/yy, US style.

    In the web.config I added a line
    <globalization uiCulture="en-GB"  culture="en-GB" />

    It made no difference at all.

    In the page Directive, I added uiCulture="en-GB"  culture="en-GB"
    No effect at all.

    I added a couple of lines:
    this.lblCulture.Text = "Culture is set as " + System.Globalization.CultureInfo.CurrentCulture.EnglishName.ToString();
    this.lblUICulture.Text = "UICulture is set as " + System.Globalization.CultureInfo.CurrentUICulture.EnglishName.ToString();

    They both return "English (United Kingdom)"

    But on that same page, dates with format {0:d} display as mm/dd/yy, like 03/25/07.

    I have tried putting formats like {0:dd/MM/yy} on all the pages, in the gridviews, detailviews, formviews etc.
    They display the dates correctly, which is fine, and nearly solves my problem because the app is only for use in the UK.
    BUT although the dates are displayed correctly, we when you try to update a record, the dates are rejected as invalid formats.


    In a DetailView, with ItemTemplate, EditTemplate and InsertTemplate for the same field all specifying dd/MM/yy,
    the date is displayed as 25/03/07. Great!

    But we cannot ENTER a date in that format.

    On the edit/update page, the date is displayed as 25/03/07, but if you change it to 26/03/07, say, the comparison validator rejects the date format. If you retype it as 3/25/07, it is accepted. Despite the {0:dd/MM/yy} format in the EditTemplate.
    Unfortunately, Joe Public will not like that.


    There are dozens of pages that display data with dates, so I went back to square one.

    New site, one page, with a detailsview and datasource to display and update a text field and a date, using {0:d} format.

    The new site had no culture settings on the page or in the config file.

    In the VWD browser it worked perfectly.
    Date displays as 25/03/07, and I can change it to 26/03/07.


    Wonderful!

    Success!

    But when I started IE7 and went to localhost/mysite,  it displayed 03/25/07.

    I added culture and UICulture settings to the config file and page, no difference.

    I made three version of my new simple page - one with plain vanilla detailsview fields with
    {0:d}, one page with template fields with {0:d}, and one page with template fields with {0:dd/MM/yy}.
    All three look right and work right inside VWD.
    In IE7, the {0:d} fields show as MM/DD/YY.
    The {0:dd/MM/yy} version display dd/mm/yy, but updates fail validation,
    you have to retype 27/03/07 as 3/27/07. (In IE7).

     

    In Windows Control panel Regional and Language settings = English (United Kingdom).

    In IE7 - Tools - Internet Options - Languages = English (United Kingdom) [en-gb]

    In Microsoft Office - Language = English (United Kingdom)


    But In VWD  -> Help, ->  ShowInfo -> Summary
     Locale = United Kingdom
     Internet Explorer - Summary - Language = English (United States)
     Microsoft Office - Summary - Language = English (United States)

    VWD has only two options for language - "English" (just the one word)
    or "Same as Windows". I tried them both, doesn't seem to make any difference.

     

    I should also mention that if I set my web.config files like the starter kits,
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    I get messages "could not find schema information .... " for everything in the config file.
    (There are many posts about this too).
    If I change that to just <configuration> the messages go away, but it makes no difference
    to the results either in the VWD browser, pane or in IE7.

     

    Like I said at the start, I already did read the documentation, and I have gone round the same circles several times now.

    Any suggestions?

     

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    03-25-2007, 3:29 PM
    • Loading...
    • LockH
    • Joined on 03-25-2007, 2:58 PM
    • Scotland, where whisky has no e.
    • Posts 544

    Correction - VWD 2005 Express SP1 (not SP2), C#, SQL 2005 Express and XP Pro SP2.

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    04-05-2007, 5:12 AM

    Hi,

    Not sure where is the exact problem, but I think this thread might be helpful for you:

    http://forums.asp.net/thread/936093.aspx

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    05-01-2007, 8:44 AM
    • Loading...
    • LockH
    • Joined on 03-25-2007, 2:58 PM
    • Scotland, where whisky has no e.
    • Posts 544

    I am afraid that did not help, and I still have the same problem.

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    05-01-2007, 10:18 AM
    • Loading...
    • LockH
    • Joined on 03-25-2007, 2:58 PM
    • Scotland, where whisky has no e.
    • Posts 544

    Maybe it will help if I post a shorter version of the problem:

    ASP.NET 2  and IIS 5.5 on XP Pro SP2, VWD SP1 or VS 2005 Pro. 

     

    British/european date formats. We like day/month/year. 

    Culture and UI culture are set to en-GB in the web.config, other apps on this machine display dates as dd/mm/yy, but dates default to mm/dd/yy format.

    I have a detailsview with template fields, with both ItemTemplate and EditTemplate versions, with date formatting {0:dd/mm/yy} which displays the dates as day/month/year, as we would like.

    <asp:TemplateField HeaderText="CloseDate" >

    <EditItemTemplate>

    <asp:TextBox id="txtCloseDateEd" Text='<%# Bind("CloseDate","{0:dd/MM/yy}") %>' runat="server" />

    <asp:RequiredFieldValidator id="reqCloseDate" ControlToValidate="txtCloseDateEd" Text="Required field" Display="Dynamic" runat="server" />

    <asp:CompareValidator id="CompareValidator2" ControlToValidate="txtCloseDateEd" Text="Should be date dd/mm/yy like 25/12/07" operator="DataTypeCheck" type="Date" Display="Dynamic" runat="server" />

    </EditItemTemplate>

    <ItemTemplate>

    <asp:TextBox id="txtCloseDate" Text='<%# Eval("CloseDate","{0:dd/MMM/yy}") %>' runat="server" />

    </ItemTemplate>

    </asp:TemplateField>

     

    The Update view displays the date in dmy format OK, eg 31/03/07, but when you amend the date, eg 30/03/07, it is rejected by the validator.  If you retype the date in mdy format, eg 03/31/07, it is accepted and the database is updated.

    So my problems are:

    - doesn't recognise default date format settings

    - when I specify date formats explicitly, they work when displaying data, but not when entering data.

     

    Any ideas?

     

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    04-26-2008, 4:37 AM
    • Loading...
    • pathowe
    • Joined on 04-26-2008, 8:21 AM
    • Posts 1

    Hi, I'm new to this forum so have only just read your post.  If you haven't already solved it have you tried using a regular expression validator to validate the date rather than the compare validator.  Here's an example of how I used a regular expression validator in one of my web apps that seems to work (although I force the users to enter four digit dates) - it does allow a user to enter 29th February on non-leap years but does stop them entering 30th February.

    <asp:TextBox ID="UserStatusDateTextBox" Height="12px" Width="200px" runat="server" Text='<%# Bind("UserStatusDate", "{0:dd/MM/yyyy}") %>' ToolTip="Format: 31/03/2008" />

    &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server" ErrorMessage="Required" ToolTip="Required" ControlToValidate="UserStatusDateTextBox" ValidationGroup="userGroup"></asp:RequiredFieldValidator>

    &nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator12" runat="server" ErrorMessage="Invalid" ControlToValidate="UserStatusDateTextBox" ValidationExpression="^(((([0-2][0-9])|(3[01]))[\/]?((0[13578])|(1[02])))|((([0-2][0-9])|(30))[\/]?((0[469])|(11)))|([0-2][0-9][\/]?02))[\/]?(19|20)\d\d$" ValidationGroup="userGroup"></asp:RegularExpressionValidator>

    Hope that helps,
    Pat.

  • Re: Culture and date setttings - inconsistency between VWD browser and IE.

    05-12-2008, 11:32 AM
    • Loading...
    • LockH
    • Joined on 03-25-2007, 2:58 PM
    • Scotland, where whisky has no e.
    • Posts 544

    The problem seems to be a bug specific to IIS 5.1 running on XP.  It seems to be inconsistent about where it looks for the date formats - different formats were used on the same page when switching between edit mode and read only. The pages would work on one machine then go wrong on another machine with identical versions of XP and VS and Sql and Office etc.

    Worked ok on win2003 with IIS6

    Eventually I went through the registries on different XP machines looking for anything to do with dates; I found one date format string that was MDY, removed it, and the problem went away. We never did find out what that registry entry was for; probably something that had been uninstalled long ago. 

     

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
Page 1 of 1 (7 items)