DatePicker SelectedDate property returns 2 digit year

3 posts, 0 answers
  1. Devaraj
    Devaraj avatar
    2 posts
    Member since:
    Mar 2009

    Posted 11 Mar 2010 Link to this post

    Hi,

    The DatePicker SelectedDate property is returning 2 digit year on a particular deployment. All other installation of the same page returns 4 digit year. It seems something enviromental causing this 2 digit year behavior. Any ideas on what could cause this?

    <%@ Page Language="C#" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <script runat="server"
        protected void RadDatePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e) { 
            Label1.Text = RadDatePicker1.SelectedDate.ToString(); 
        } 
    </script> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <div> 
            <p> 
                <telerik:RadDatePicker ID="RadDatePicker1" runat="server" AutoPostBack="True" OnSelectedDateChanged="RadDatePicker1_SelectedDateChanged"
                    <DateInput AutoPostBack="True"
                    </DateInput> 
                    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
                    </Calendar> 
                    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton> 
                </telerik:RadDatePicker> 
                &nbsp;<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></p
            <p> 
        </div> 
        </form> 
    </body> 
    </html> 


    Thanks,
    Dev.
  2. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 11 Mar 2010 Link to this post

    I notice that you're using the ToString() method, which uses the current culture used on the computer running the page. If you want to maintain a consistent date rendering, you should use the ToString(format) method instead and format the date yourself.

    That's the only way I can think of, that will force the correct date format on all machines.

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Devaraj
    Devaraj avatar
    2 posts
    Member since:
    Mar 2009

    Posted 12 Mar 2010 Link to this post

    You are right. Specifying a date format to the ToString() method does force this particular site to return the 4 digit year. I was trying to see if I could fix this problem without making code changes but it looks like I might have to. Thanks for your help.
Back to Top