Wednesday 8 October 2014

How to Use Calender Control in Asp.Net C#

No comments    
categories: , , ,
Calender Control





Html Coding


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

             OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
      
        <asp:TextBox ID="TextBox1" runat="server"

             Height="26px" Width="248px"></asp:TextBox>
       
   
    </div>
    </form>
</body>
</html>

C# Coding for LongDate


 protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        TextBox1.Text = Calendar1.SelectedDate.ToLongDateString();
    }


C# Coding for ShortDate


 protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();

    }














                                              

0 comments:

Post a Comment