-->

22 December 2019

Asp.Net Calender Control

  Asp.Net CS By Example       22 December 2019




  The Calendar Control :
     The Calendar control used to display a calendar.
we can use the calendar as a date picker or to display a list of upcoming events.


Syntax:
<asp:Calendar ID="calSelectDate" SelectionMode="DayWeekMonth" runat="server"  />


The Calendar control supports the following properties (this is not a complete list):
S.N. Property Description
1) ID Set the uniqe value to control to access in code-behind code.
2) DayNameFormat Used to specify the appearance of the days of the week.
Possible values are FirstLetter, FirstTwoLetters, Full, Short, and Shortest.
3) NextMonthText Used to specify the text that appears for the next month link.
4) NextPrevFormat Used to specify the format of the next month and previous month link.
Possible values are CustomText, FullMonth, and ShortMonth.
5) PrevMonthText Used to specify the text that appears for the previous month link.
6) SelectedDate Used to get or set the selected date.
7) SelectedDates Used to get or set a collection of selected dates.
8) SelectionMode Used to specify how dates are selected. Possible values are Day,
DayWeek, DayWeekMonth, and None.
9) SelectMonthText Used to specify the text that appears for selecting a month.
10) SelectWeekText Used to specify the text that appears for selecting a week.
11) ShowDayHeader Used to hide or display the day names at the top of the Calendar control.
12) ShowNextPrevMonth Used to hide or display the links for the next and previous months.
13) ShowTitle Used to hide or display the title bar displayed at the top of the calendar.
14) TitleFormat Used to format the title bar. Possible values are Month and MonthYear.
15) TodaysDate Used to specify the current date. This property defaults to the current date
on the server.
16) VisibleDate Used to specify the month displayed by the Calendar control.
This property defaults to displaying the month that contains the date specified by TodaysDate.

The Calendar control also supports the following events:
S.N. Method Description
1) DayRender Raised as each day is rendered.
2) SelectionChanged Raised when a new day, week, or month is selected.
3) VisibleMonthChanged Raised when the next or previous month link is clicked.
The SelectionMode property enables we to change the behavior of the calendar so that
we can not only select days, but also select weeks or months.

Code: CalenderExm01.aspx ( Design Code )

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CalenderExm01.aspx.cs" 
Inherits="LearnAsp.Net.GridViewControl.CalenderExm01" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Calendar ID="calSelectDate" runat="server"></asp:Calendar>
    </div>
    </form>
</body>
</html>


Output:

logoblog

Thanks for reading Asp.Net Calender Control

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.