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 8591613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:34:00+00:00 2026-06-11T23:34:00+00:00

I’ve got a very interesting bug with a jQueryUI datepicker and an UpdatePanel where

  • 0

I’ve got a very interesting bug with a jQueryUI datepicker and an UpdatePanel where the datepicker’s chosen date is about 100 years off. jQuery is version 1.6.2, and jQueryUI is version 1.8.14. Here’s the rough layout:

<asp:UpdatePanel ID="myUpdatePanel" runat="server">
  <ContentTemplate>
    <asp:DropDownList ID="myDdl" runat="server" AutoPostBack="true">
      <asp:ListItem Value="foo" Text="Foo" />
      <asp:ListItem Value="bar" Text="Bar" />
    </asp:DropDownList>
    <asp:TextBox ID="myText" runat="server" CssClass="dateText" />
  </ContentTemplate
</asp:UpdatePanel>
<script type='text/javscript'>
  $(document).ready(function()
  {
     $('.dateText').datepicker({ changeYear: true, showButtonPanel: true, yearRange: '-2:+2' });
  }

  function pageLoad(sender, args)
  {
    if (args._isPartialLoad == true)
    {
      $('.dateText').datepicker({ changeYear: true, showButtonPanel: true, yearRange: '-2:+2' });
    }
  }
</script>

So I’ve got an UpdatePanel that contains a dropdown that causes a postback when it’s changed, as well as a text box. I’ve got jQueryUI setting the textbox up as a datepicker. Note that all this is contained in a jQueryUI modal dialog.

So here’s what happens:

  1. When the dialog opens, the dropdown is the default focus. Pressing a key on the keyboard will change the selection in the dropdown, but will not initiate postback.
  2. After having changed the value of the dropdown with the keyboard, click in the textbox. The partial postback starts (because the dropdown lost focus) and the jQueryUI DatePicker comes up showing the current month and year (February 2012 as of writing).
  3. The partial postback probably finishes before we have a chance to do anything with the datepicker.
  4. After the postback completes, click one of the forward/backward month buttons on the datepicker. If you press backward, it goes to November 2010. If you press forward, it goes to January 2010.
  5. After changing the month with the buttons, click a day in the calendar. The datepicker closes and puts a date in the textbox. If you pressed backward in step 4, the date is in November 1899. If you pressed forward in step 4, the date is in January 1900.

It seems that the datepicker gets confused when it’s initialized when it’s already open after the partial postback. I know that the datepicker setup doesn’t survive the partial postback and that I need to reinitialize it in the pageLoad function.

I can tell if this is happening by checking if $('.ui-datepicker-title').length is greater than zero when setting up the datepicker in pageLoad. But I don’t know what to do from there. After verifying that it’s happening, I’ve tried the following in pageLoad before setting up the datepicker:

  • $('.dateText').unbind();
  • $('.dateText').datepicker('destroy');
  • $('#ui-datepicker-div').remove();

It either does the same thing or closes itself and doesn’t come up at all anymore.

How can I fix this?

Update: I tried it with jQueryUI 1.8.18 and jQuery 1.7.1 (latest versions at time of writing) and the problem still happens.

Update 2: I’ve managed to work around the problem by supplying a function in the options for onChangeMonthYear when the datepicker is initialized in pageLoad. If the year parameter of that event is either 1899 or 1900, I set the datepicker’s date to one month back or forward from now (respectively). That sets the textbox’s content, which I don’t want, so I then set the value of the textbox to ”. The net result is that the datepicker acts normally.

I’d still like to understand this whole problem better, though, so I know if it’s a bug in jQueryUI that I should file or whether I should be doing something different elsewhere.

Update 3: Still happening with ASP.NET 4, jQuery 1.7.2 and jQueryUI 1.8.21. I tested it on an otherwise blank page with a setup just like what’s described here, and saw the same behavior. I’m calling this a jQueryUI bug. It’s filed here.

UPDATE 4: I’ve reproduced the problem without ASP.NET in this jsfiddle.

  • 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-06-11T23:34:02+00:00Added an answer on June 11, 2026 at 11:34 pm

    According to comments on the jQueryUI bug I filed, this is not a situation that should ever really happen. But I think it’s going to, so I’m going to post my workaround here for future reference.

    Given an input with ID myInput:

    var changingDate = false;
    $('#myInput').datepicker({onChangeMonthYear:function(year, month, inst)
      {
        if (changingDate == false)
        {
          changingDate = true; //I set the date later which would call this
              //and cause infinite recursion, so use this flag to stop that
          if (year == 1899 || year == 1900)
          {
            var now = new Date(); //what the picker would have had selected
                //before clicking the forward/backward month button
            if (year == 1899) //I clicked backward
            {
               now.setMonth(new.getMonth() - 1);
            }
            else if (year == 1900) //I clicked forward
            {
               now.setMonth(now.getMonth() + 1);
            }
            $(this).datepicker('setDate', now);
          }
          changingDate = false;
        }
        }
      });
    

    Use the onChangeMonthYear option shown above when initializing the picker from the pageLoad function:

    function pageLoad(sender, args)
    {
      if (args._isPartialLoad == true) //called because of UpdatePanel refresh
      {
        //set up datepicker as shown above
      }
    }
    
    • 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
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
i got an object with contents of html markup in it, for example: string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and

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.