Abu
Abu

Reputation: 39

How to insert calendar control in asp.net

I have a panel. in that panel there is one text box for some input and another one for taking date from calendar control. I have put calendar control below the second text box(i.e. txtDate), but I don't want it to be displayed when the page is loaded, instead I want a small image of calendar and on clicking that image a calendar should pop up and selected date must be captured by txtdate textbox.

Please help me with .aspx and .cs file. I'm using asp.net with C#.

Upvotes: 1

Views: 17899

Answers (3)

Surendra Singh
Surendra Singh

Reputation: 1

You can user use Jquery library in your project. Below is the example

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" 
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js">        
    </script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js">    
    </script>
    <script >
        $(document).ready( function() {
                $("[id=^datepicker]").datepicker();
            } );
        </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <p>Date: <asp:TextBox   id="datepicker" runat="server">
    </p>

    </form>

    </body>
</html>

Upvotes: -1

Misam
Misam

Reputation: 4389

An ASP.NET based solution for calender control is best explained here

But I would suggest you to go forward with Ajax based solution Ajax Calender

Calender control in AJax toolkit

Upvotes: 0

Ebad Masood
Ebad Masood

Reputation: 2379

Use AJAX Calender Extender. Here is the Sample Markup Code:

                    <asp:CalendarExtender ID="ControlIDHere" runat="server" Enabled="True"
                        TargetControlID="TextBoxIDHere" PopupButtonID="CalenderImageIDHere" Format="MM/dd/yyyy">
                    </asp:CalendarExtender>

Upvotes: 3

Related Questions