Hi all,
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.
I am very new to AJAX, javascript and sclient side scripting in general.
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.
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.
from what I have read I need to manually wire this back up after the post back.
1) I don't really understand why. on my master page I have:
<script type="text/javascript">
$(function() {
$(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});
});
</script>
which picks up my input boxes with the mydatepickerclass assigned. and all works. Why would this stop working on the postback.
2) How do I fix this.... how do I wire it up so that after a postback in an updatepanel it still works.
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.
edit
I have the following code in my usercontrol where the update is happening:
<asp:UpdatePanel ID="HistoryUpdatePanel" runat="server">
<ContentTemplate>
<%-- Start of Company History section --%>
<fieldset>
<legend>Activity History</legend>
<script type="text/javascript">
$(function() {
$(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});
});
</script>
<div>
<asp:ListBox ID="listBoxHistoryTypes" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="listBoxHistoryTypes_IndexChanged" />
<label>Date From:</label><asp:TextBox class="mydatepickerclass" ID="txtdatefrom" runat="server" />
<label>Date To:</label><input class="mydatepickerclass" type="text" />
<asp:TextBox class="mydatepickerclass" ID="txtdateto" runat="server" />
<asp:Button ID="btnFilterSearch" runat="server" Text="Filter Results" OnClick="btnFilterSearch_Click" />
</div>
</fieldset>
</ContentTemplate>
Does the script inside the updatepanel not rewire it?
Thanks
Jon Hawkins