using …

Pure C#

02 Nov 2008 için Arşiv

RadDateTimePicker Client Object

Yazan: esersahin 02/11/2008

http://www.telerik.com/help/aspnet-ajax/calendar_clientsideraddatetimepicker.html

The following table lists the most important methods of the RadDateTimePicker client-side object.

Name Parameters Return Type Description
get_selectedDate none Date Returns the selected date and time, or null if no date is selected.
set_selectedDate Date none Assigns the value of the date/time picker.
clear none none Clears the selection, leaving the value as unassigned.
isEmpty none boolean Returns true if the value is unassigned.
get_maxDate none Date Returns the latest date  and time the user can select.
set_maxDate Date none Sets the latest date and time the user can select.
get_minDate none Date Returns the earliest date and time the user can select.
set_minDate Date none Sets the earliest date and time the user can select.
get_focusedDate none Date Returns the date that determines the view the popup calendar uses when the value of the date/time picker is not assigned.
set_focusedDate Date none Sets the date that determines the view the popup calendar uses when the value of the date/time picker is not assigned.
showPopup integer, integer none Displays the popup calendar at the specified coordinates. If the two parameters are omitted, the popup appears below the input area.
showTimePopup integer, integer none Displays the popup time view at the specified coordinates. If the two parameters are omitted, the popup appears below the input area.
hidePopup none none Hides the popup calendar if it is showing.
hideTimePopup none none Hides the popup time view if it is showing.
togglePopup none none Toggles the visible state of the popup calendar.
toggleTimePopup none none Toggles the visible state of the popup time view.
isPopupVisible none boolean Returns whether the popup calendar is visible.
isTimePopupVisible none boolean Returns whether the popup time view is visible.
get_calendar none RadCalendar Returns a reference to the client object for the popup calendar.
get_timeView none RadTimeView Returns a reference to the client object for the popup time view.
get_dateInput none RadDateInput Returns a reference to the client object for the input area. For details on using this object, see the RadInput documentation.
get_element none HTML element Returns the DOM element for the entire RadDateTimePicker control.
get_textBox none HTML element Returns the DOM element for the text box that implements the input area.
get_popupButton none HTML element Returns the DOM element for the calendar popup button.
get_timePopupButton none HTML element returns the DOM element for the time popup button.
get_popupContainer none HTML element Returns the DOM element for the <DIV> that contains the popup calendar.
get_timePopupContainer none HTML element Returns the DOM element for the <DIV> that contains the popup time view.
getElementDimensions HTML element rectangle Returns the dimensions of the specified child element.
getElementPosition HTML element point Returns the x and y coordinates of the specified child element.

See Also

Client-Side Basics

Yazı kategorisi: Telerik | » yorum bırak;

RadCalendar Client-Side Basics

Yazan: esersahin 02/11/2008

http://www.telerik.com/help/aspnet-ajax/calendar_clientsidebasics.html

The RadCalendar controls provide a flexible client-side API. You can easily interact with the controls in the browser using their client-side objects. In addition to a variety of client-side events, the client-side object model lets you achieve complicated tasks while avoiding unnecessary post-backs.

Getting the client-side object

All the API methods are accessible via the registered JavaScript objects for each control. A global variable with the same name as the ClientID of the control is available for each control:

[JavaScript] Getting the client-side object Copy Code
var calendar = $find(“<%= RadCalendar1.ClientID %>“);
var datepicker = $find(“
<%= RadDatePicker1.ClientID %>“;
var timepicker = $find(“
<%= RadTimePicker1.ClientID %>“;
var datetimepicker = $find(“
<%= RadDateTimePicker1.ClientID %>“;

Getting a reference to child elements

For the RadDatePicker, RadTimePicker, and RadDateTimePicker, you can access client-side objects for the child elements using the methods listed below:

Object Type Method Supported by
RadInput get_dateInput() RadDatePicker, RadTimePicker, RadDateTimePicker
RadCalendar get_calendar() RadDatePicker, RadDateTimePicker
RadTimeView get_timeView() RadTimePicker, RadDateTimePicker

In addition, you can access the DOM objects for various parts of the controls using the methods listed below:

Element Method Supported by
Entire control get_element() RadCalendar, RadDatePicker, RadTimePicker, RadDateTimePicker
CalendarPopupButton get_popupButton() RadDatePicker, RadDateTimePicker
TimePopupButton get_timePopupButton() RadTimePicker, RadDateTimePicker
TextBox of input area get_textBox() RadDatePicker, RadTimePicker, RadDateTimePicker
DIV for popup calendar get_popupContainer() RadDatePicker, RadDateTimePicker
DIV for popup time view get_timePopupContainer() RadTimePicker, RadDateTimePicker

Getting and setting the selected date

The RadCalendar client object represents dates as triplets. Each triplet is an array of three integer values, which specify the year, month, and day of a date, in that order.

To get the selected date or dates on a RadCalendar control, use the get_selectedDates() method. This methods returns an array. If no date is selected, the array has length 0. If the calendar does not support multi-select mode, then the array has at most one element. Each date in the array is a triplet:

[JavaScript] Getting the selected dates Copy Code
var calendar = $find(“<%= RadCalendar1.ClientID %>”);
var dates
= calendar.get_selectedDates();
for (int i = 0; i < dates.length; i++)
{
var date = dates[i];
var year
= date[0];
var month
= date[1];
var day
= date[2];
if (year < 2000)
calendar.unselectDate(date);
}

To set the selected date on a RadCalendar control, use the selectDate() or selectDates() method:

[JavaScript] Setting the selected dates Copy Code
function SelectTodayAndTomorrow()
{
var todaysDate = new Date();
var todayTriplet
= [todaysDate.getFullYear(), todaysDate.getMonth()+1, todaysDate.getDate()];
var tomorrowTriplet
= [todaysDate.getFullYear(), todaysDate.getMonth()+1, todaysDate.getDate() + 1];
var selectedDates
= [todayTriplet, tomorrowTriplet];
var calendar
= $find(“<%=RadCalendar1.ClientID%>”);
calendar.selectDates(selectedDates, true);
}

To get the selected date on a RadDatePicker, RadTimePicker, or RadDateTimePicker control, use the get_selectedDate method. This method returns a Date object. To set the selected date, use the set_selectedDate method:

[JavaScript] get_selectedDate and set_selectedDate Copy Code
function incrementDate(picker)
{
var date = picker.get_selectedDate();
date.setDate(date.getDate()
+ 1);
picker.set_selectedDate(date);
}

On RadTimeView and RadDateTimeView, you can also use the getTime and setTime methods of the embedded RadTimeView:

[JavaScript] getTime, setTime Copy Code
function getTime()
{
var picker = $find(“<%=RadDateTimePicker1.ClientID%>”);
var view
= picker.get_timeView();
alert(view.getTime());
}

Getting and setting minimum and maximum values

The following methods get or set the minimum and maximum values:

Method Supported By Description
get_rangeMinDate() RadCalendar Returns the triplet for the minimum date that the user can select.
set_rangeMinDate(triplet) RadCalendar Sets the minimum date to the date represented by a triplet.
get_rangeMaxDate() RadCalendar Returns the triplet for the maximum date that the user can select.
set_rangeMaxDate(triplet) RadCalendar Sets the maximum date to the date represented by a triplet.
get_minDate() RadDatePicker, RadTimePicker, RadDateTimePicker Returns the minimum date as a Date object.
set_minDate(date) RadDatePicker, RadTimePicker, RadDateTimePicker If the date is valid, sets the minimum date.
get_maxDate() RadDatePicker, RadTimePicker, RadDateTimePicker Returns the maximum date as a Date object.
set_maxDate(date) RadDatePicker, RadTimePicker, RadDateTimePicker If the date is valid, sets the maximum date.

Clearing selected values

On RadCalendar, you can unselect individual dates using the unselectDate or unselectDates method:

[JavaScript] Clearing the calendar Copy Code
function clearCalendar()
{
var calendar = $find(“<%= RadCalendar1.ClientID %>”);
var dates
= calendar.get_selectedDates();
calendar.unselectDates(dates);
}

On RadDatePicker, RadTimePicker, and RadDateTimePicker, you can use the clear() method:

[JavaScript] Clearing RadDatePicker, RadTimePicker, and RadDateTimePicker Copy Code
function clearPickers()
{
var datepicker = $find(“<%= RadDatePicker1.ClientID %>”;
datepicker.clear();
var timepicker
= $find(“<%= RadTimePicker1.ClientID %>”;
timepicker.clear();
var datetimepicker
= $find(“<%= RadDateTimePicker1.ClientID %>”;
datetimePicker.clear();
}

Enabling and disabling the RadDatePicker, RadTimePicker, or RadDateTimePicker controls

To enable or disable a RadDatePicker, RadTimePicker, or RadDateTimePicker control, you need to call the set_enabled(true/false) client-side method of the Picker client-side object:

[JavaScript] Enabling and disabling RadDatePicker Copy Code
<asp:ScriptManager id=“ScriptManager1″ runat=“server”></asp:ScriptManager>
<telerik:RadDatePicker ID=“RadDatePicker1″ runat=“server”></telerik:RadDatePicker>
<br />
<script type=“text/javascript”>
function disable()
{
var picker = $find(“<%= RadDatePicker1.ClientID %>”);
picker.set_enabled(false);
}
function enable()
{
var picker = $find(“<%= RadDatePicker1.ClientID %>”);
picker.set_enabled(true);
}
</script>
<input type=“button” value=“disable” onclick=“disable()” />
<input type=“button” value=“enable” onclick=“enable()” />

Showing and hiding the popup

The RadDatePicker, RadTimePicker, and RadDateTimePicker objects include a number of methods for showing and hiding the popup controls:

Method Supported By Description
showPopup() RadDatePicker, RadDateTimePicker Displays the popup calendar. Optionally you can specify a position for the popup.
hidePopup() RadDatePicker, RadDateTimePicker Hides the popup calendar if it is visible.
togglePopup() RadDatePicker, RadDateTimePicker Hides the popup calendar if it is visible and shows the popup if it is not.
showTimePopup() RadTimePicker, RadDateTimePicker Displays the popup time view. Optionally you can specify a position for the popup.
hideTimePopup() RadTimePicker, RadDateTimePicker Hides the popup time view if it is visible.
toggleTimePopup() RadTimePicker, RadDateTimePicker Hides the popup time view if it is visible and shows the popup if it is not.

See Also

Yazı kategorisi: Telerik | » yorum bırak;

Find DatePickers on page client side, without knowing client id of picker

Yazan: esersahin 02/11/2008

http://www.telerik.com/community/forums/thread/b311D-etmcc.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<%@ Register Assembly=”RadInput.Net2″ Namespace=”Telerik.WebControls” TagPrefix=”rad” %>

<%@ Register Assembly=”RadCalendar.Net2″ Namespace=”Telerik.WebControls” TagPrefix=”rad” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
</head>
<script type=”text/javascript”>
debugger;
var datepickers = [];
window.onload = function()
{
for(var element in window)
{
if (window[element] && typeof(window[element].TogglePopup) == “function”)
{
datepickers[datepickers.length] = window[element];
}
}
}
</script>
<body>
<form id=”form1″ runat=”server”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server” />
<div>

<rad:RadDateInput ID=”RadDateInput1″ runat=”server”>
</rad:RadDateInput>

<rad:RadDatePicker ID=”RadDatePicker1″ runat=”server”>
</rad:RadDatePicker>
<rad:RadDatePicker ID=”RadDatePicker2″ runat=”server”>
</rad:RadDatePicker>
</div>
</form>
</body>
</html>

Yazı kategorisi: Telerik | » yorum bırak;

RadCalendar Value

Yazan: esersahin 02/11/2008

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default9.aspx.cs” Inherits=”Default9″ %>
<%@ Register Assembly=”RadCalendar.Net2″ Namespace=”Telerik.WebControls” TagPrefix=”rad” %>
<%@ Register Assembly=”RadInput.Net2″ Namespace=”Telerik.WebControls” TagPrefix=”rad” %>

<!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>
<script type=”text/javascript” language=”javascript”>
function Validate()
{
var dtp1 = window["<%= RadDatePicker1.ClientID %>"];
var dtp2 = window["<%= RadDatePicker2.ClientID %>"];
if (dtp1.DateInput.GetValue() < dtp2.DateInput.GetValue())
{
dtp2.DateInput.SetValue(“”);
}
}
</script>

<form id=”form1″ runat=”server”>
<div>
<rad:RadDatePicker ID=”RadDatePicker1″ runat=”server”></rad:RadDatePicker>

<rad:RadDatePicker ID=”RadDatePicker2″ runat=”server”>
<ClientEvents OnDateSelected=”Validate” />
</rad:RadDatePicker>

</div>
</form>
</body>
</html>

Yazı kategorisi: Telerik | » yorum bırak;

RadCalendar for ASP.NET

Yazan: esersahin 02/11/2008

http://www.telerik.com/help/aspnet/calendar/clientsideapi.html

Client-Side API
See Also
Telerik RadCalendar Client-Side > Client-Side API

Glossary Item Box

Telerik RadCalendar  exposes several JavaScript structures: functions and events which allow you to control the behavior of the calendar on the client-side.

All the client-side functions that take or return date values use a custom interchange format, for transferring dates. The format (due to javascript as Date object regarding calendars different than Gregorian) is as follows: [2005, 11, 15]. This is a triplet array where the first position is the year, the second is the month and the third is the day.

The selected dates array returned by some functions is an array, where every cell of is a date representation triplet. This representation looks like this, [ [2005, 11, 15], [2005, 11, 16], [2005, 11, 17], [2005, 11, 18], [2005, 11, 19], [2005, 11, 20] ]

The  main elements of the RadCalendar Client-Side API are shown below.

Element

Description
RadCalendar

The Telerik RadCalendar object in javascript

GetSelectedDates

Returns an array of date triplets, representing the selected dates contained in the calendar

SelectDate(date, navigate)

Takes a triplet representation of a date, and if valid selects it in the calendar. The second input parameter is of boolean type and denotes whether the calendar should change its visual state by navigating visually to the selected date. You have to use the true value as an input, if false is used the date will be selected but the calendar won’t change its visual state.

SelectDates(dates, navigate)

Takes an array of triplets representing dates and if valid selects them in the calendar. The second input parameter is Boolean type and denotes whether the calendar should change its visual state by navigating visually to the last date of the array. One must use true value as an input, if false is used the dates will be selected but the calendar won’t change its visual state.

UnselectDate(date)

Takes a triplet representation of a date and if valid, deselects it in the calendar.

UnselectDates(dates)

Takes an array of triplets representing dates and if valid, deselects them in the calendar.

NavigateToDate(date) Takes a triplet representation of a date and if valid navigates the calendar view to the supplied date.
This method is a navigation enhancement and does not perform a selection.
GetRangeMinDate() Returns an array of date triplets, representing the RangeMinDate of the calendar.
SetRangeMinDate(date) Takes an array of triplets representing the date and if valid set the RangeMinDate to it.
GetRangeMaxDate() Returns an array of date triplets, representing the RangeMaxDate of the calendar.
SetRangeMaxDate(date) Takes an array of triplets representing the date and if valid set the RangeMaxDate to it.
CalculateDateFromStep(step) Returns a triplet representation of a date which is calculated from the current calendar view with some step. For example, if the step is -3, the function returns three months before, if it is 3 – it returns a date, representing three months later.
RangeValidation.IsDateValid(date) Takes an array of date triplets and return true/false if the date is/is not in the calendar date range, defined by RangeMinDate and RangeMaxDate.

See Also

Yazı kategorisi: Telerik | » yorum bırak;

RadCalendar for ASP.NET AJAX

Yazan: esersahin 02/11/2008

http://demos.telerik.com/ASPNET/Prometheus/Calendar/Examples/DatePicker/ClientAPI/DefaultCS.aspx

Yazı kategorisi: Telerik | » yorum bırak;