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

  • Home
  • SEARCH
  • 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 4338818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:07:58+00:00 2026-05-21T11:07:58+00:00

I have an ASP.NET dropdownlist called #ddlDateRange that contains several items. Possible values in

  • 0

I have an ASP.NET dropdownlist called #ddlDateRange that contains several items. Possible values in the dropdownlist are:

Year - Current
Year - Previous
Year - Custom

I have two textboxes called txtStartDate and txtEndDate which are filled with values based on what the user selects from the dropdown. (i.e. txtStartDate = ’01-01-2010′ and txtEndDate = ’12-31-2010′) if the user selects Year – Previous.

I also have two calendar controls to the right of the text boxes. These jquery calendar controls allow an end user to select a custom date range IF they choose Custom Date. The jquery portion of the page is:

        $("#<%#ddlDateRange.ClientID%>").blur(function() {
            var value = $('#<%#ddlDateRange.ClientID%>').val();
            var lowerCaseValue = value.toLowerCase();

            if (lowerCaseValue.indexOf('custom') > -1) {
                alert('You selected custom date range: ' + lowerCaseValue);
                // enable the calendar controls                    
            } else {
                alert('You DID NOT select a custom date range: ' + lowerCaseValue);
                // disable the calendar controls
                // .dp-choose-date
                $("a").click(function(e) {
                    alert('howdy!');
                    e.preventDefault();
                });
            }
        });

The code is working correctly except in the else block. I want to disable the anchor tag that has the class of “dp-choose-date”.

<div class="caption">Start Date:</div>
<div class="dateCell">
    <input name="ctl00$Tabs$Panel1$txtStartDate" type="text" 
           id="ctl00_Tabs_Panel1_txtStartDate" class="date-pick" 
           style="width:125px;" />
    <a href="#" class="dp-choose-date" title="Choose date">Choose date</a>
</div>
<br />

I am aware that I can use preventDefault to prevent the default action when clicking on a hyperlink, but the alert(‘Howdy’) never gets fired off when I attempt to debug in Firebug. I believe the reason is that because I’m not clicking on the link right after the dropdown loses focus which makes sense.

So my question is, how do I disable the link? I also tried:

$("a .dp-choose-date").click(function(e) {
    alert('Howdy!');
    e.preventDefault();
});

as my selector. But I am still able to click on the link, which I do not want. In the rendered markup, the class “date-pick” which is used in the textbox generates the anchor tag with the “dp-choose-date” attribute, so I’m not sure if I can toggle this class.

If anyone has any suggestions, I’m all ears…

  • 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-21T11:07:59+00:00Added an answer on May 21, 2026 at 11:07 am

    MY suggestion is to do something like this:

    var blurred = true
    $("#").focus(function(){
        blurred = false;
    });
    $("#").blur(function() {
        var value = $('#').val();
        var lowerCaseValue = value.toLowerCase();
    
        if (lowerCaseValue.indexOf('custom') > -1) {
            alert('You selected custom date range: ' + lowerCaseValue);
            // enable the calendar controls                    
        } else {
            alert('You DID NOT select a custom date range: ' + lowerCaseValue);
            // disable the calendar controls
            // .dp-choose-date
            blurred = true;
        }
    });
    
    $("a.dp-choose-date").click(function(e) {
        if ( blurred ){
            alert('howdy!');
            e.preventDefault();
        }
    });
    
    

    Right now you are adding a click event to the a tags every time there is a loss of focus. This is not only unnecessary but can lead to performance issues as the user interacts with the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DropDownList called (DDL) in ASP.net page, I want that DDL contains
Is there anyway to have items in an ASP.NET DropDownList have either their Text
I have asp.net form that contains fields. When I access this window, my javascript
What's the best method for handling a situation where you have an ASP.Net Dropdownlist
I have an ASP.NET GridView with a DropDownList (in an Item Template) and a
I have a asp.net 2.0 web site with numerous asp:DropDownList controls. The DropDownList control
I have a ASP.NET page with an asp:button that is not visible. I can't
I have an ASP.NET DDL that looks like this when I view source: <select
I have the following JavaScript to disable a dropdownlist in a ASP.NET page, which
I am using ASP.NET 3.5 I have a drop-down list called lstCountry with an

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.