0

I have a update panel which updates each 1 minutes.

In side it, I have a two input files, when I click on each one, a datepicker function is called. I include these scripts for the datepicker

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"/>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css"/>

Also, I have this script in my head tag

<script>
        $(function () {
            $("#CldrFrom, #CldrTo").datepicker();
        });
    </script>

The datepicker works before the update panel updates the content. but after that, It is not working anymore.

what should I do please?

Note

I already have function pageLoad(sender, args) in one of my scripts but I don't think this could cause the problem

user3432257
  • 415
  • 3
  • 10
  • 22
  • possible duplicate of [Asp.Net UpdatePanel in Gridview Jquery DatePicker](http://stackoverflow.com/questions/3341623/asp-net-updatepanel-in-gridview-jquery-datepicker) – Aristos Apr 14 '14 at 12:25
  • Try running `$("#CldrFrom, #CldrTo").datepicker();` again after each update. – wrxsti Apr 14 '14 at 12:26
  • @Aristos it is not duplicated my friend, that is a gridview, which makes it a compltelely different – user3432257 Apr 14 '14 at 12:27
  • @user3432257 Is not the gridview the issue, but the code for the UpdatePanel. See my answer there, is exactly the same way as here. – Aristos Apr 14 '14 at 12:28
  • @wrxsti where please? do you mean in the `pageload` function ? – user3432257 Apr 14 '14 at 12:28
  • yes in the pageload as the last thing you do within the function or as a callback. – wrxsti Apr 14 '14 at 12:28

2 Answers2

2

You need to reinitialise the date picker after each refresh in update pannel, Use this code

$(document).ready(function () {
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded)
});

function PageLoaded(sender, args) {
    $("#CldrFrom, #CldrTo").datepicker();

}
Anoop Joshi P
  • 25,373
  • 8
  • 32
  • 53
0
$(function () 
{
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedUserFunc)
});

function PageLoadedSUserFunc(sender, args) 
{
    $("#FromDate, #ToDate").datePicker();
}
//Select by Id method is used here. 

Assuming that FromDate and ToDate are existing in the updatepanel which will get refreshed everytime whenever pageload happens.

Jaroslav Kadlec
  • 2,505
  • 4
  • 32
  • 43