DatePicker disappears after postback

坚强是说给别人听的谎言 提交于 2019-11-29 09:23:05

问题


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!


回答1:


Use pageLoad, it fires on partial postbacks:

   function pageLoad() { 
      $("#EditFromDate").datepicker({ ... });

   } 

$(document).ready() and pageLoad() are not the same!



来源:https://stackoverflow.com/questions/7970412/datepicker-disappears-after-postback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!