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

Problems Obtaining Date from Java

1 Answer 45 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 2
Ron asked on 05 Dec 2012, 02:45 AM
Hello,

I am simply trying to obtain the date selected from the RadDatePicker control through javascript as I am trying to pass the value to another page as a parameter for an SQL query the page performs when loading.  However, I am having a problem with the format the date is returing.  I have tried both get_selectedDates and get_textBox with no luck in returning a date that is in a datetime format for the parameter.  With get_seletedDates I am getting a long formatted style not in the correct format while get_textBox doesn't return a date value, only that it is an HTMLelement or something along that lines.

Is there a way to get the date that is in the text box portion of the datepicker to return how it actually shows in the date picket, for instance 12/10/2012?

Thanks,
Ron

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Dec 2012, 04:24 AM
Hi Ron,

You can format the selecteddate to achieve your scenario. Following is the sample code that I tried to achieve your scenario.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
</telerik:RadDatePicker>
<asp:Button ID="Button1" runat="server" OnClientClick="OnClientClick(); return false;" />

JS:
<script type="text/javascript">
    function OnClientClick() {
        var datepicker = $find("<%= RadDatePicker1.ClientID %>");
        var date = datepicker.get_selectedDate();
        var day = date.format("MM/dd/yyyy");
        alert(day);
    }
</script>

Hope this helps.

Regards,
Princy.
Tags
Calendar
Asked by
Ron
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or