I've got an application that uses jQuery UI DatePicker on an ASP.NET textbox control.
The control is working as intended, but I've noticed that when you postback from a server call (via submit button), the entered value gets lost in the application.
Was wondering if you all have experienced this? What measures that you have to do to prevent this?
<asp:TextBox runat="server" ID="txtCallsMadeFrom" class="field" EnableViewState="true">
var callsMadeFromId = '#<%=txtCallsMadeFrom.ClientID %>';
jQuery(callsMadeFromId).datepicker({ showOn: "button", buttonImage: "../images/calendar.gif", altFormat: 'dd/mm/yy', buttonImageOnly: true, onSelect: function () { } });
I faced this issue as well and even after trying to set view state on page or for control it did not workout. The approach to use a hidden field required to me manage sync between date field and the hidden field as the user was playing with the dates. So I decided to set the date again on document.ready as given in the post here, hope this helps.
http://www.himanshusaxena.net/asp-net-text-box-with-jquery-ui-date-picker-value-lost-on-a-post-back/
You could consider saving the Textbox's value in a hidden field. I do that with Jquery tabcontrols as they also forget which tab is selected during a postback.
Make sure that you haven't put <%@ Page EnableViewState="false"%>
in .. if you have done so you can still turn on the view state of individual control by <asp:TextBox runat="server" ID="txtCallsMadeFrom" class="field" ViewStateMode="Enabled">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With