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

Telerik Rad Calendar

2 Answers 132 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mo
Top achievements
Rank 1
Mo asked on 24 Feb 2009, 06:05 PM
How do I get the new date selected by the user? With the following code when I click on a date I keep on getting the date I assigned in pageload. The value never changes. What am I missing?? I just want to get the date the user selects on the calendar control.

Why does  e.SelectedDates has always one date in it and that date is the one I assign in pageload.?? I just the need the date, it should be straight forward.



<telerik:RadCalendar ID="telerikCalendar" runat="server" Font-Names="Arial,Verdana,Tahoma"
                ForeColor="Black" Style="border-color: #ececec"
                OnSelectionChanged="SelectedDateChange" EnableMultiSelect="false"
                AutoPostBack="true">
                    </telerik:RadCalendar>

In PageLoad:
if( !IsPostBack )
        {
            telerikCalendar.SelectedDate = DateTime.Now;
                 
          }




protected void SelectedDateChange(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
    {
        
       DateTime t = (DateTime) telerikCalendar.SelectedDate;
        if ( e.SelectedDates.Count > 0)
        {
            strDateSelected = e.SelectedDates[0].Date.ToString();
         
        }
    }

It has been 7 hours since I posted my question and I have got no response yet. That is very disappointing.

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 25 Feb 2009, 07:51 AM
Hi Mo,

The response time of Telerik team members in the forums is up to 72 hours. For more information about response time of support tickets, please refer to:

http://www.telerik.com/support/technical-support-options.aspx

Now to your question - actually, everything is working as expected and your code is OK. Here is a complete runnable example:

<%@ Page Language="C#" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
     
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            telerikCalendar.SelectedDate = DateTime.Now; 
        } 
    } 
 
    protected void SelectedDateChange(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e) 
    { 
        if (e.SelectedDates.Count > 0) 
        { 
            string strDateSelected = e.SelectedDates[0].Date.ToString(); 
            Label1.Text = strDateSelected
        } 
    } 
     
</script> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadCalendar ID="telerikCalendar" runat="server" EnableMultiSelect="false" 
    OnSelectionChanged="SelectedDateChange" AutoPostBack="true" /> 
 
<br /><br /> 
 
The new selected date is: <asp:Label ID="Label1" runat="server" Text="" /> 
 
</form> 
</body> 
</html> 
 


All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mo
Top achievements
Rank 1
answered on 27 Feb 2009, 07:16 PM
Response time of 72 hours,  might want to look into it.

Your response is not very helpful to me as I dont see much difference between my code and yours and beside that It is obvious the problem is not at the code level.

My problem is still outstanding and even the admin could not point me in any other direction to resolve the issue.

I have implemented another calendar control and I am quite contented with it and therefore  I will pass on the Telerik control.




Thanks for making an effort.

 
Tags
Calendar
Asked by
Mo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Mo
Top achievements
Rank 1
Share this question
or