Wednesday, 6 August 2014

Disable jQuery UI DatePicker Calendar On Button Click In Asp.Net

8/06/2014 - By Pranav Singh 0

This article will show you how you can use a jQuery UI date time picker calendar and  after selecting the date disable the calendar control on button click on asp.net application.



So for this article first we will create a new asp.net application and add the below code into the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DateTimePicker.aspx.cs"
    Inherits="WebApplication7.DateTimePicker" %>

<!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>Disable jQuery UI DatePicker Calendar On Button Click In Asp.Net</title>
    <script src="http://code.jquery.com/jquery-2.1.1.js"></script>
    <script src="https://code.jquery.com/ui/jquery-ui-git.js"></script>
    <link href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" rel="stylesheet" />
    <style>
        div.ui-datepicker
        {
            font-size: 11px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $('#<%=txtdob.ClientID%>').datepicker();
        })

        function DisableCalander() {
            $('#<%=txtdob.ClientID%>').datepicker('disable');
            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Select Date:
        <asp:TextBox ID="txtdob" runat="server" />
        <asp:Button ID="btndisable" runat="server" Text="Disable" OnClientClick="javascript:return DisableCalander();" />
    </div>
    </form>
</body>
</html>

In above code just check the below mention jQuery code.

    <script type="text/javascript">
        $(function () {
            $('#<%=txtdob.ClientID%>').datepicker();
        })

        function DisableCalander() {
            $('#<%=txtdob.ClientID%>').datepicker('disable');
            return false;
        }
    </script>


In above code I have first assigned the date picker and in second I am disabling the date picker control. Now we have done run the page and check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top