Call a Javascript Function after UpdatePanel Postback Issue

前端 未结 3 841
孤城傲影
孤城傲影 2020-12-16 13:54

I basically have in my UpdatePanel a literal that generates a javascript array based on a method in my codebehind.

I don\'t have an issue when it comes to loading my

相关标签:
3条回答
  • 2020-12-16 14:02

    You could create a simple webservice method that returns the javascript array to the page whenever required and wrap the call to that webservice in a javascript method. Invoking the javascript method to refresh the array in memory on the browser side will work better than expecting the js array literal to be parsed again on UpdatePanel postbacks with any success.

    0 讨论(0)
  • 2020-12-16 14:16

    you can add the following code in Page_Load event:

    ScriptManager.RegisterStartupScript(Me.rptGridAlbum, rptGridAlbum.GetType, "scriptname", "somejavascript", True)
    

    This will fire the javascript on your page after the AJAX callback.

    MSDN

    0 讨论(0)
  • 2020-12-16 14:24
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm != null) {
        prm.add_endRequest(function (sender, e) {
            if (sender._postBackSettings.panelsToUpdate != null) {
                DisplayCurrentTime(); // here your javascript function
            }
        });
    };
    
    0 讨论(0)
提交回复
热议问题