I have a TextBox say Enter Range, when the user click in the test box, i am getting radcalander and giving the choice to select date range, when user select dates i am getting one by one dates in the text box,
But i want only two dates should be selected and display in the text box at a time
can you please solve the problem,i want multiple selection and display which one is min and second is max that is start date and enddate. the code is given below
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%
@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%
@ 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">
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadScheduler1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadScheduler ID="RadScheduler1"
runat="server"
AllowDelete="True"
AllowEdit="True"
AllowInsert="True"
DataEndField="End"
DataKeyField="ID"
DataRecurrenceField="RecurrenceRule"
DataRecurrenceParentKeyField="RecurrenceParentID"
DataSourceID="SqlDataSource1"
DataStartField="Start"
DataSubjectField="Subject"
HoursPanelTimeFormat="h:mm tt"
SelectedDate="2007-11-29" OnAppointmentInsert="RadScheduler1_AppointmentInsert">
</telerik:RadScheduler>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SchedulerDataConnectionString %>"
DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End], [UserID], [RoomID], [RecurrenceRule], [RecurrenceParentID], [Annotations]) VALUES (@Subject, @Start, @End, @UserID, @RoomID, @RecurrenceRule, @RecurrenceParentID, @Annotations)"
SelectCommand="SELECT [ID], [Subject], [Start], [End], [UserID], [RoomID], [RecurrenceRule], [RecurrenceParentID], [Annotations] FROM [Appointments]"
UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [UserID] = @UserID, [RoomID] = @RoomID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [Annotations] = @Annotations WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Subject" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="End" Type="DateTime" />
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="RoomID" Type="Int32" />
<asp:Parameter Name="RecurrenceRule" Type="String" />
<asp:Parameter Name="RecurrenceParentID" Type="Int32" />
<asp:Parameter Name="Annotations" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Subject" Type="String" />
<asp:Parameter Name="Start" Type="DateTime" />
<asp:Parameter Name="End" Type="DateTime" />
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="RoomID" Type="Int32" />
<asp:Parameter Name="RecurrenceRule" Type="String" />
<asp:Parameter Name="RecurrenceParentID" Type="Int32" />
<asp:Parameter Name="Annotations" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function
OnDateSelected(sender, args)
{
var date = new Date(args.Date[0], (args.Date[1]-1), args.Date[2]);
$get(
"TextBox2").value += date.format("yyyy/MM/dd");
$get(
"TextBox2").value += " ";
$find(
"PopEx2").hidePopup();
}
function
pageLoad()
{
$find(
'PopEx').hidePopup();
}
</script>
</telerik:RadCodeBlock>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblSelectDate" runat="server" Text="Enter Date Range"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<telerik:RadCalendar ID="RadCalendar1" runat="server" AutoPostBack="true" OnSelectionChanged="RadCalendar1_SelectionChanged">
</telerik:RadCalendar>
<cc1:PopupControlExtender ID="PopEx" runat="server" TargetControlID="TextBox1"
PopupControlID="RadCalendar1" Position="Bottom" />
</ContentTemplate>
</
asp:UpdatePanel>
</form>
</
body>
</
html>
Code Behind --------------------------------------------
protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
{
TextBox1.Text +=
String.Format("{0} ", e.SelectedDates[e.SelectedDates.Count - 1].Date.ToString("yyyy/MM/dd"));
}