This is a migrated thread and some comments may be shown as answers.

Datepicker with client date format

5 Answers 221 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 11 Jul 2014, 06:06 PM
I want the datepicker to use the client settings for date format. 
This works if I run it from visual studio. Once I publish it though the datepicker no longer reflects my system date formats. 

On my system the date format is yyyy-mm-dd and I see this format used when running from visual studio.
When I run it after publishing it - I see dd/mm/yyyy

What do I have to do to make this work for published and installed sites?
What am I missing?

I have attached a very basic sample project that whipped up to test it and it also does this in the same way as our main app.

Thanks for your help.

I have also pasted the entire web page below (not very long)

01.<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
02. 
03.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
04. 
06.<head runat="server">
07.    <title></title>
08.    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
09.</head>
10.<body>
11.    <form id="form1" runat="server">
12.    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
13.        <Scripts>
14.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
15.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
16.            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
17.        </Scripts>
18.    </telerik:RadScriptManager>
19. 
20. 
21.    <telerik:RadDatePicker ID="dte_startDate" runat="server"></telerik:RadDatePicker>
22. 
23.    <script type="text/javascript">
24.        //Put your JavaScript code here.
25.    </script>
26.    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
27.    </telerik:RadAjaxManager>
28.    <div>
29. 
30.    </div>
31.    </form>
32.</body>
33.</html>

5 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 16 Jul 2014, 11:57 AM
Hi Jonathan,

The reason for that is the culture of the severer differs from the one on your local machine. A possible solution is to set a culture on the entire page or set a DisplayDateFormat of the DatePicker control. Please check out the following code snippets for additional information.
Setting culture:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" Culture="en-US" %>
Setting DisplayDateFormat :
<telerik:RadDatePicker ID="dte_startDate" runat="server">
    <DateInput DisplayDateFormat="yyyy-mm-dd"></DateInput>
</telerik:RadDatePicker>

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jonathan
Top achievements
Rank 1
answered on 16 Jul 2014, 02:22 PM
Thanks for the response. I think you misunderstood though. My server is my local machine. When I run the app via Visual Studio on my local machine - it uses my local machine's date format. When I publish the same application onto my local machine it doesn't use my local machine date format. 

NOTE: there is only 1 computer involved in all of this - the only difference is running via Visual Studio debugging or running it as a local published site. 

I do not want to set a fixed date format -

I want the date format the user sees to reflect the settings they have on their computer. I do see this happen when I run my app via Visual Studio but not when I publish it. 
0
Kostadin
Telerik team
answered on 21 Jul 2014, 11:05 AM
Hello Jonathan,

Know that by default the culture is changed automatically when you opened the page under a different user culture setting. Since you host the page on the same machine please make sure that you did not apply any culture on the IIS. Also you could place a break point in your code behind and check what is the culture when you host the page and when you run in from the VisualStudio.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jonathan
Top achievements
Rank 1
answered on 29 Jul 2014, 08:52 PM
If I understand correctly then - it is the IIS user that ultimately determines the culture and formats. The culture of the end user on their own desktop has no control over how the controls display dates etc. 
0
Accepted
Princy
Top achievements
Rank 2
answered on 30 Jul 2014, 06:40 AM
Hi Jonathan

Users can set the UI culture and culture in their browsers. 

For example, in Microsoft Internet Explorer, on the Tools menu, users can click Internet Options, on the General tab, click Language, and then set their language preference.

If the enableClientBasedCulture attribute of the globalization element in the Web.config file is set to true, ASP.NET can set the UI culture and culture for a Web page automatically, based on the values that are sent by a browser.

It is not a best practice to rely exclusively on browser settings to determine the UI culture for a page. 

Users frequently use browsers that are not set to their preferences,so it is always better to take culture from IIS.

Thanks
Princy.




Tags
Calendar
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Jonathan
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or