jquery datepicker ms ajax updatepanel doesn't work after post back

后端 未结 9 1652
囚心锁ツ
囚心锁ツ 2020-12-05 05:42

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 AJ

相关标签:
9条回答
  • 2020-12-05 06:08

    Another easy way is to take out the date text box from the Update Panel. This way, the post back made by the Update Panel does not affect the date text box

    0 讨论(0)
  • 2020-12-05 06:09

    I know this post is old - but just place your jquery datepicker outside of the update panel - should work 100%...

    0 讨论(0)
  • 2020-12-05 06:10

    When use asp:ScriptManager and Sys.WebForms.PageRequestManager does not working, you can try to use following code:

    Sys.Application.add_load(LoadHandler);
    
    //This load handler solved update panel did not bind date picker after partial postback 
    function LoadHandler() {
        $(document).ready(function () {
            $(".datepicker").datepicker({
                dateFormat: "M d, yy",
                changeMonth: true,
                changeYear: true,
                onSelect: function (dateText, ubst) { 
                   //your code here... 
                }
            }).val();
        });
    }
    
    0 讨论(0)
  • 2020-12-05 06:12

    I know this is old but ... try replace:

    $(document).ready(function() {

    with:

    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function () {

    0 讨论(0)
  • 2020-12-05 06:12

    Instead of doing this there is a simple alternative.

    In the postback of the element in update panel add this code

    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "asddas", "getjquerydate();",   True)
    

    And this in javascript

    function getjquerydate() {
    
    $(".datepicker").datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        minDate: 1,
        dateFormat: 'dd/mm/yy',
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true
    });
    

    }

    After Partial postback in updated panel it again call the datepicker function

    0 讨论(0)
  • 2020-12-05 06:12
    $(document).ready(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().beginAsyncPostBack();
            function EndRequestHandler(sender, args) {
                $('.mydatepickerclass').datepicker({ dateFormat: 'dd-mm-yy' });
            }
        });
    

    You can do like this. in this case it will work always ;))

    0 讨论(0)
提交回复
热议问题