locked
How to set Culture Info... RRS feed

  • Question

  • User-333218881 posted

    Hi All,

            I want to set culture info for my full application. where're i say datetime.now, it should give datetime based on my cultureinfo i set. how do i do it?

    thanx n advance...

       


    Tuesday, July 13, 2010 7:55 AM

Answers

  • User-815382200 posted
  • Check this link: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

  • I will quote what is most important:

  •  

  • To set the UI culture and culture for all pages, add a globalization section to the Web.config file, and then set the uiculture and culture attributes, as shown in the following example:

    <globalization uiCulture="es" culture="es-MX" />
  • 
    
  • To set the UI culture and culture for an individual page, set the Culture and UICulture attributes of the @ Page directive, as shown in the following example:

    <%@ Page UICulture="es" Culture="es-MX" %>
    

     

     

     

     

    Alternatively, if you want to handle datetime object only, you can use DateTime.Now.ToString("YY-MM-dd") - with any pattern you like.

     

    Hope it helps...

  • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 13, 2010 9:18 AM
  • User-25924017 posted

    I want to set culture info for my full application

    Then set it in web.config in system.web section add this, change culture you want, this will apply this culture on whole application:

    <globalization uiCulture="en-US" culture="en-US"/>  


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 13, 2010 9:22 AM
  • User-1418680850 posted

    Hi,

    In the Web.config file, set the below setting based on your CultureInfo. It will apply to the full application.

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 14, 2010 6:47 AM
  • All replies

    • User-1802908944 posted

      this is woking code and i am implemented successfully

      DateTime.Parse(DateTime.Now.ToString("dd-MM-yyyy"), new CultureInfo("en-GB"));

      happy coding


      Tuesday, July 13, 2010 9:15 AM
    • User-815382200 posted
    • Check this link: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

    • I will quote what is most important:

    •  

    • To set the UI culture and culture for all pages, add a globalization section to the Web.config file, and then set the uiculture and culture attributes, as shown in the following example:

      <globalization uiCulture="es" culture="es-MX" />
    • 
      
    • To set the UI culture and culture for an individual page, set the Culture and UICulture attributes of the @ Page directive, as shown in the following example:

      <%@ Page UICulture="es" Culture="es-MX" %>
      

       

       

       

       

      Alternatively, if you want to handle datetime object only, you can use DateTime.Now.ToString("YY-MM-dd") - with any pattern you like.

       

      Hope it helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 13, 2010 9:18 AM
  • User-25924017 posted

    I want to set culture info for my full application

    Then set it in web.config in system.web section add this, change culture you want, this will apply this culture on whole application:

    <globalization uiCulture="en-US" culture="en-US"/>  


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 13, 2010 9:22 AM
  • User-1418680850 posted

    Hi,

    In the Web.config file, set the below setting based on your CultureInfo. It will apply to the full application.

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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 14, 2010 6:47 AM
  • User-242433875 posted

    There are 4 ways of specifying the culture settings for the application. All of them are discussed below.

    1. Specifying Culture setting at application level - using Web.Config
      <system.web>
          <globalization uiCulture="en-US" culture="en-US"/>
      </system.web>
    2. Specifying Culture setting at Page Level
      <%@ Page UICulture="en-US" Culture="en-US" %>
    3. Specifying Culture setting in code-behind (at Page Level)
          Protected Overrides Sub InitializeCulture()
              System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB")
              System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB")
          End Sub
       Protected Overrides Sub InitializeCulture()
          System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US")
          System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-US")
      End Sub
    4.  Specifying Culture setting at control level - It usually have 2 properties like "Culture" and "UICulture" which can be explicitly set to any value.

    Hope, this answers your query.

    - Ankur

    Monday, July 19, 2010 10:48 AM
  • User-242433875 posted

    There are 4 ways of specifying the culture settings for the application. All of them are discussed below.

    1. Specifying Culture setting at application level - using Web.Config
      <system.web>
          <globalization uiCulture="en-US" culture="en-US"/>
      </system.web>
    2. Specifying Culture setting at Page Level
      <%@ Page UICulture="en-US" Culture="en-US" %>
    3. Specifying Culture setting in code-behind (at Page Level)
          Protected Overrides Sub InitializeCulture()
              System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB")
              System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB")
          End Sub
       Protected Overrides Sub InitializeCulture()
          System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US")
          System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-US")
      End Sub
    4.  Specifying Culture setting at control level - It usually have 2 properties like "Culture" and "UICulture" which can be explicitly set to any value.

    Hope, this answers your query.

    - Ankur

    Monday, July 19, 2010 10:49 AM