title: jquery datepicker ms ajax updatepanel doesn't work after post back
body: <p>So I did some reading of the related questions and had some interesting stuff but did not find my answer, at least did not understand the answer.</p>
  
  <p>I am very new to AJAX, javascript and sclient side scripting in general.</p>
  
  <p>I have been using C# asp.net for a bit and recently added some updatepanels to my side to smooth so of the user controls and bits being updated so that the page was not reloaded each time.  All works brilliantly and I was very happy with it till I decided to try and use some JQuery.</p>
  
  <p>I have picked up the datepicker from ui.jquery.js which is cool and works great on a normal page.  My problem arrives when I do a postback from within an updatepanel.  The datepicker just stops working.</p>
  
  <p>from what I have read I need to manually wire this back up after the post back.</p>
  
  <p>1)  I don't really understand why.  on my master page I have:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function() {
          $(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>which picks up my input boxes with the mydatepickerclass assigned. and all works.  Why would this stop working on the postback.</p>
  
  <p>2)  How do I fix this.... how do I wire it up so that after a postback in an updatepanel it still works.</p>
  
  <p>I understand that the ID might change on a postback, I think but as I am using classes I don't know what is going wrong.</p>
  
  <p><strong>edit</strong></p>
  
  <p>I have the following code in my usercontrol where the update is happening:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="HistoryUpdatePanel" runat="server"&gt;
  &lt;ContentTemplate&gt;
      &lt;%-- Start of Company History section --%&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Activity History&lt;/legend&gt;
  
             &lt;script type="text/javascript"&gt;
                $(function() {
                $(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});
                });
             &lt;/script&gt;            
  
          &lt;div&gt;
              &lt;asp:ListBox ID="listBoxHistoryTypes" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="listBoxHistoryTypes_IndexChanged" /&gt;
              &lt;label&gt;Date From:&lt;/label&gt;&lt;asp:TextBox class="mydatepickerclass" ID="txtdatefrom" runat="server" /&gt;
              &lt;label&gt;Date To:&lt;/label&gt;&lt;input class="mydatepickerclass" type="text" /&gt;
              &lt;asp:TextBox class="mydatepickerclass" ID="txtdateto" runat="server" /&gt;
              &lt;asp:Button ID="btnFilterSearch" runat="server" Text="Filter Results" OnClick="btnFilterSearch_Click" /&gt;
          &lt;/div&gt;
  
  
      &lt;/fieldset&gt;
  &lt;/ContentTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>Does the script inside the updatepanel not rewire it?</p>
  
  <p>Thanks</p>
  
  <p>Jon Hawkins</p>