I have an asp:TextBox associated to a jquery DatePicker. This input has a onTextChangedEvent that updates a Literal Control.
All this code is inside an UpdatePanel so the Literal Control changes but the page doesn’t refresh.
The problem I’m facing is that when the event fires, the image that displays the DatePicker disappears. Here’s a piece of my code:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:TextBox runat="server" OnTextChanged="EditFromDate_TextChanged"
AutoPostBack="true"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
Then I have:
$(document).ready(function()
{
$("#EditFromDate").datepicker({ ... });
});
Should I put the code that initiates the DatePicker elsewhere?
I’ve tried placing it in Page Load using Page.RegisterStartup but same result.
Thanks!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Use pageLoad, it fires on partial postbacks:
function pageLoad() {
$("#EditFromDate").datepicker({ ... });
}
$(document).ready() and pageLoad() are not the same!
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0