From: JimLad on
Hi,

ASP.NET 3.5

We are creating a 3-tier ASP.NET Web Application that needs just to
understand dates as UK shortdate format (dd/MM/yyyy). It will only be
used in the UK on intranet. I often come across web server and client
machine that are incorrectly set up so I want to protect the app from
these incorrectly set up hosts.

I understand the safe date formats for passing through to the
database. SQLParameters pass through a non-ambiguous format and also
that 'yyyyMMdd' is also a safe format. So ignore the database side of
things - I get that.

At the moment all the bound controls are done as follows:
<%# Bind("spouse_date_of_birth","{0:dd/MM/yyyy}") %>

This nicely controls the inputs, but would it be better to put the
following line in web.config:
<globalization uiCulture="en" culture="en-GB" />
and then specify the short date format on the page:
<%# Bind("spouse_date_of_birth","{0:d}") %>

Also, if we fail to convert all strings in the UI layer and then
convert them in the BLL or DLL layer, what culture would those
assemblies/DLLs use in the date conversion? Do they use the values
specified in the web.config or do you specify them separately?

One thing I am sure about is that I want to isolate the ASP.NET app
from the culture settings on the web server and the client machine.

Cheers,

James
From: Alexey Smirnov on
On Jan 22, 11:52 am, JimLad <jamesdbi...(a)yahoo.co.uk> wrote:
> Hi,
>
> ASP.NET 3.5
>
> We are creating a 3-tier ASP.NET Web Application that needs just to
> understand dates as UK shortdate format (dd/MM/yyyy). It will only be
> used in the UK on intranet. I often come across web server and client
> machine that are incorrectly set up so I want to protect the app from
> these incorrectly set up hosts.
>
> I understand the safe date formats for passing through to the
> database. SQLParameters pass through a non-ambiguous format and also
> that 'yyyyMMdd' is also a safe format. So ignore the database side of
> things - I get that.
>
> At the moment all the bound controls are done as follows:
> <%# Bind("spouse_date_of_birth","{0:dd/MM/yyyy}") %>
>
> This nicely controls the inputs, but would it be better to put the
> following line in web.config:
> <globalization uiCulture="en" culture="en-GB" />
> and then specify the short date format on the page:
> <%# Bind("spouse_date_of_birth","{0:d}") %>
>
> Also, if we fail to convert all strings in the UI layer and then
> convert them in the BLL or DLL layer, what culture would those
> assemblies/DLLs use in the date conversion? Do they use the values
> specified in the web.config or do you specify them separately?
>
> One thing I am sure about is that I want to isolate the ASP.NET app
> from the culture settings on the web server and the client machine.
>
> Cheers,
>
> James

Just use <globalization uiCulture="en-GB" culture="en-GB" /> and your
date will be automatically shown in UK format. You will not need to
bother about format in <%# Bind(...)%> statement. ASP.NET uses web
application settings from the web.config file. It doesn't rely on
client or server settings.

From: JimLad on
On 22 Jan, 11:32, Alexey Smirnov <alexey.smir...(a)gmail.com> wrote:
> On Jan 22, 11:52 am, JimLad <jamesdbi...(a)yahoo.co.uk> wrote:
>
>
>
>
>
> > Hi,
>
> > ASP.NET 3.5
>
> > We are creating a 3-tier ASP.NET Web Application that needs just to
> > understand dates as UK shortdate format (dd/MM/yyyy). It will only be
> > used in the UK on intranet. I often come across web server and client
> > machine that are incorrectly set up so I want to protect the app from
> > these incorrectly set up hosts.
>
> > I understand the safe date formats for passing through to the
> > database. SQLParameters pass through a non-ambiguous format and also
> > that 'yyyyMMdd' is also a safe format. So ignore the database side of
> > things - I get that.
>
> > At the moment all the bound controls are done as follows:
> > <%# Bind("spouse_date_of_birth","{0:dd/MM/yyyy}") %>
>
> > This nicely controls the inputs, but would it be better to put the
> > following line in web.config:
> > <globalization uiCulture="en" culture="en-GB" />
> > and then specify the short date format on the page:
> > <%# Bind("spouse_date_of_birth","{0:d}") %>
>
> > Also, if we fail to convert all strings in the UI layer and then
> > convert them in the BLL or DLL layer, what culture would those
> > assemblies/DLLs use in the date conversion? Do they use the values
> > specified in the web.config or do you specify them separately?
>
> > One thing I am sure about is that I want to isolate the ASP.NET app
> > from the culture settings on the web server and the client machine.
>
> > Cheers,
>
> > James
>
> Just use <globalization uiCulture="en-GB" culture="en-GB" /> and your
> date will be automatically shown in UK format. You will not need to
> bother about format in <%# Bind(...)%> statement. ASP.NET uses web
> application settings from the web.config file. It doesn't rely on
> client or server settings.- Hide quoted text -
>
> - Show quoted text -

Thanks.

How would I set the Culture and UI Culture for the BLL and DAL layers
in separate VB.NET dlls?

James
From: Patrice on
Hi,

You shouldn't. The idea is to convert to a text representation at the very
end and from a text representation as soon as possible (that is in the UI
layer). Your BLL and DAL should deal with dates, and shouldn't have anything
to convert. Have you run into an issue or is it a question you ask just in
case ?

--
Patrice


"JimLad" <jamesdbirch(a)yahoo.co.uk> a �crit dans le message de
news:5e03c5b5-c032-49a1-87fa-1f0402dc4c46(a)y23g2000yqm.googlegroups.com...
On 22 Jan, 11:32, Alexey Smirnov <alexey.smir...(a)gmail.com> wrote:
> On Jan 22, 11:52 am, JimLad <jamesdbi...(a)yahoo.co.uk> wrote:
>
>
>
>
>
> > Hi,
>
> > ASP.NET 3.5
>
> > We are creating a 3-tier ASP.NET Web Application that needs just to
> > understand dates as UK shortdate format (dd/MM/yyyy). It will only be
> > used in the UK on intranet. I often come across web server and client
> > machine that are incorrectly set up so I want to protect the app from
> > these incorrectly set up hosts.
>
> > I understand the safe date formats for passing through to the
> > database. SQLParameters pass through a non-ambiguous format and also
> > that 'yyyyMMdd' is also a safe format. So ignore the database side of
> > things - I get that.
>
> > At the moment all the bound controls are done as follows:
> > <%# Bind("spouse_date_of_birth","{0:dd/MM/yyyy}") %>
>
> > This nicely controls the inputs, but would it be better to put the
> > following line in web.config:
> > <globalization uiCulture="en" culture="en-GB" />
> > and then specify the short date format on the page:
> > <%# Bind("spouse_date_of_birth","{0:d}") %>
>
> > Also, if we fail to convert all strings in the UI layer and then
> > convert them in the BLL or DLL layer, what culture would those
> > assemblies/DLLs use in the date conversion? Do they use the values
> > specified in the web.config or do you specify them separately?
>
> > One thing I am sure about is that I want to isolate the ASP.NET app
> > from the culture settings on the web server and the client machine.
>
> > Cheers,
>
> > James
>
> Just use <globalization uiCulture="en-GB" culture="en-GB" /> and your
> date will be automatically shown in UK format. You will not need to
> bother about format in <%# Bind(...)%> statement. ASP.NET uses web
> application settings from the web.config file. It doesn't rely on
> client or server settings.- Hide quoted text -
>
> - Show quoted text -

Thanks.

How would I set the Culture and UI Culture for the BLL and DAL layers
in separate VB.NET dlls?

James

From: Alexey Smirnov on
On Jan 22, 7:24 pm, JimLad <jamesdbi...(a)yahoo.co.uk> wrote:
> On 22 Jan, 11:32, Alexey Smirnov <alexey.smir...(a)gmail.com> wrote:
>
>
>
>
>
> > On Jan 22, 11:52 am, JimLad <jamesdbi...(a)yahoo.co.uk> wrote:
>
> > > Hi,
>
> > > ASP.NET 3.5
>
> > > We are creating a 3-tier ASP.NET Web Application that needs just to
> > > understand dates as UK shortdate format (dd/MM/yyyy). It will only be
> > > used in the UK on intranet. I often come across web server and client
> > > machine that are incorrectly set up so I want to protect the app from
> > > these incorrectly set up hosts.
>
> > > I understand the safe date formats for passing through to the
> > > database. SQLParameters pass through a non-ambiguous format and also
> > > that 'yyyyMMdd' is also a safe format. So ignore the database side of
> > > things - I get that.
>
> > > At the moment all the bound controls are done as follows:
> > > <%# Bind("spouse_date_of_birth","{0:dd/MM/yyyy}") %>
>
> > > This nicely controls the inputs, but would it be better to put the
> > > following line in web.config:
> > > <globalization uiCulture="en" culture="en-GB" />
> > > and then specify the short date format on the page:
> > > <%# Bind("spouse_date_of_birth","{0:d}") %>
>
> > > Also, if we fail to convert all strings in the UI layer and then
> > > convert them in the BLL or DLL layer, what culture would those
> > > assemblies/DLLs use in the date conversion? Do they use the values
> > > specified in the web.config or do you specify them separately?
>
> > > One thing I am sure about is that I want to isolate the ASP.NET app
> > > from the culture settings on the web server and the client machine.
>
> > > Cheers,
>
> > > James
>
> > Just use <globalization uiCulture="en-GB" culture="en-GB" /> and your
> > date will be automatically shown in UK format. You will not need to
> > bother about format in <%# Bind(...)%> statement. ASP.NET uses web
> > application settings from the web.config file. It doesn't rely on
> > client or server settings.- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks.
>
> How would I set the Culture and UI Culture for the BLL and DAL layers
> in separate VB.NET dlls?
>
> James

CultureInfo.CurrentCulture

If you use dates you normally don't need it. If any string comparisons
must be done, either use current culture or a culture-invariant string
comparison.

CultureInfo.CurrentCulture
CultureInfo.InvariantCulture

More about CultureInfo
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx

Hope this helps
 |  Next  |  Last
Pages: 1 2
Prev: CMS system
Next: Cant find System.Windows.Xps