Calendar Control in ASP.NET

ASP.NET हमें अपने वेब एप्लीकेशन के लिए Calendar Control प्रदान करता है जिसका उपयोग किसी वेब पेज पर Calendar प्रदर्शित करने के लिए किया जाता है। ASP.NET Calendar Control एक महीने का कैलेंडर प्रदर्शित करता है जो उपयोगकर्ता को तिथियों का चयन करने और अगले और पिछले महीनों में जाने की अनुमति देता है।

डिफ़ॉल्ट रूप से, यह Control चालू माह का नाम, सप्ताह के दिनों के लिए दिन शीर्षक, महीने के दिन और पिछले या अगले महीने में नेविगेशन के लिए arrow characters (< और >) प्रदर्शित करता है।

कैलेंडर जटिल और शक्तिशाली Webserver Control है जिसका उपयोग आप अपने वेब पेज पर कैलेंडर सुविधा जोड़ने के लिए कर सकते हैं। हम 0 A.D. और 9999 A.D के बीच किसी भी तारीख को प्रदर्शित करने के लिए कैलेंडर नियंत्रण का उपयोग कर सकते हैं।

Calendar Control को इस प्रकार दर्शाया गया है:

<asp:Calendar ID="Calendar1" runat="server" </asp:Calendar>

Calendar Control का प्रयोग (Use of Calendar Control)

Calendar Control एक ऐसा कण्ट्रोल जो निम्नलिखित क्षमताएं प्रदान करता है

  • एक बार में एक महीना प्रदर्शित करना
  • एक दिन, एक सप्ताह या एक महीने का चयन
  • दिनों की श्रेणी का चयन
  • एक महीने से दुसरे महीने पर जाना
  • प्रोग्रामेटिक रूप से दिनों के प्रदर्शन को नियंत्रित करना

Calendar Control की मुख्य properties निम्‍नलिखित है

SN Property Description
1 DayNameFormat Enables you to specify the appearance of the days of the week. Possible values are first letter first two letter, full short and shortest.
2 NextMonthText Enables you to specify the text that appears for the next month link.
3 NextPreventFormat Enables you to specify the format of the next month. and previous month link. possible values are custom text. full month and short month.

Calendar Control Code Example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="calendardemo._Default" %>
<!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">
      
         <div>
            <h3> Your Birthday:</h3>
            <asp:Calendar ID="Calendar1" runat="server  SelectionMode="DayWeekMonth" onselectionchanged="Calendar1_SelectionChanged">
            </asp:Calendar>
         </div>
         
         <p>Todays date is: 
            <asp:Label ID="lblday" runat="server"></asp:Label>
         </p>
         
         <p>Your Birthday is: 
            <asp:Label ID="lblbday" runat="server"></asp:Label>
         </p>
         
      </form>
   </body>
</html>

The event handler for the event SelectionChanged:


protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
   lblday.Text = Calendar1.TodaysDate.ToShortDateString();
   lblbday.Text = Calendar1.SelectedDate.ToShortDateString();
}

error: Content is protected !!