Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 641329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:03:04+00:00 2026-05-13T21:03:04+00:00

I’m fairly new to jQuery and I’ve been looking for a decent free datepicker

  • 0

I’m fairly new to jQuery and I’ve been looking for a decent free datepicker for a while now. I am quite satisfied with jQuery UI’s datepicker but I’ve hit a snag. The project where I’m using this requires that I have an icon beside the textbox. While this is fairly easy, I don’t know how to dynamically disable the icon.

There are two things I’m interested in knowing:

  1. How can I dynamically change the disabled status of the datepicker from code-behind so that it triggers on postback?
  2. Is it possible to make it’s disabled status dependent on the textbox that it is attached to? (i.e. if

    <asp:TextBox Id="txtMyTextBox" Enabled="false">

then datepicker gets disabled as well.

This is the code I’ve been using for the datepicker.

<script type="text/javascript">
    $(function() {
        $("*[id$='txtMyTextBox']").datepicker({
            changeMonth: true,
            changeYear: true,
            showOn: 'button',
            buttonImage: '/images/icon-calendar.gif',
            buttonImageOnly: true
        });
    });
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:03:04+00:00Added an answer on May 13, 2026 at 9:03 pm

    Well if your using the jquery U.I datepicker why not use the built in disable command? So on post back you just disable it.

    Of course the textbox will be disabled as well but I am assuming that’s what you want too.

    // jquery ui has a built in icon that shows up automatically
    http://jqueryui.com/demos/datepicker/#icon-trigger

    // how to disable jquery ui.
    http://jqueryui.com/demos/datepicker/#method-disable

    Here is how to disable the box once a post back happens. I am not clear if you want this to happen right after they enter something in the textbox or not though.

    Default.aspx

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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></title>
        <link href="ui.all.css" rel="stylesheet" type="text/css" />
            <link href="ui.core.css" rel="stylesheet" type="text/css" />
        <link href="ui.datepicker.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
    
    
        <script type="text/javascript">
            $(function()
            {
    
                $("#txtMyTextBox").datepicker({ showOn: 'button', buttonImage: 'images/calendar.gif', buttonImageOnly: true });
                var disabled = $('#txtMyTextBox').attr('disabled');
                if (disabled == true)
                {
                    $("#txtMyTextBox").datepicker('disable');
                }
                else
                {
                    $("#txtMyTextBox").datepicker('enable');
                }
    
    
            });
    
    
    </script>
    
    
    
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="txtMyTextBox" runat="server" Enabled="false"></asp:TextBox>
            <asp:Button ID="enable" runat="server" Text="enable" onclick="enable_Click" 
                style="width: 56px" />
            <asp:Button ID="disable" runat="server" Text="disable" 
                onclick="disable_Click" />
    
        </div>
    
        </form>
    </body>
    </html>
    

    code behind

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page 
    {
    
    
        protected void enable_Click(object sender, EventArgs e)
        {
            txtMyTextBox.Enabled = true;
        }
        protected void disable_Click(object sender, EventArgs e)
        {
            txtMyTextBox.Enabled = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.