Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Thursday, 5 February 2015

Introduction: 

In this article we learn how to use Ajax calendar extendar control to show/display calendar to select the date .
 Ajax made it very easy by providing the CalendarExtendar control to use Calendar in web application. We can implement it on the TextBox. Now when user click on TextBox a calendar appears and let the user select the appropriate date from the calendar. Thus it is very user friendly and convenient way to use calendar both for end user as well as developer.
Implementation: 
Place a ScriptManager control, a TextBox and Label control from the Visual studio standard toolkit.

Also place CalendarExtendar control from the AjaxControlToolKit if you have already installed theAjaxControlToolkit, if not then add ajaxtoolkit to visual studio.
  <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

   <asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>
        <asp:CalendarExtender ID="CalendarExtender1"
        PopupButtonID="txtDOB"
        PopupPosition="BottomLeft"
         TargetControlID="txtDOB"
          Format="dd/MM/yyyy"
          runat="server">
        </asp:CalendarExtender>

  <asp:Button ID="btnSubmit" runat="server" Text="Submit " onclick="btnSubmit_Click" />

        <asp:Label ID="lblDOB" runat="server" Text=""></asp:Label>

C#.Net Code to implement CalendarExtendar control of Ajax in asp.net

  • Now in code behind file (.aspx.cs) write the code on Submit button click event as:
protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblDOB.Text = "Your Date of Birth is: " + txtDOB.Text;
    }

VB.Net Code to implement CalendarExtendar control of Ajax in asp.net

  • Now in code behind file (.aspx.vb) write the code on Submit button click event as:
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
                    lblDOB.Text = "Your Date of Birth is: " + txtDOB.Text

End Sub

0 comments:

Post a Comment