Niloo Niloo - 3 days ago 4
ASP.NET (C#) Question

Execute javascript after a partial postback of an updatepanel?

I have a page that add tree file script to it .

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/init.js"></script>
<script type="text/javascript" src="js/easing.js"></script>


I have a updatepanel with a dropdownlist. When run SelectedIndexChanged event (partial postback of an updatepanel), don't execute javascript .

Answer

Use

function pageLoad(sender, args) {

  InitialiseSettings();
}

function InitialiseSettings(){
    // replace your DOM Loaded settings here. 
    // If you already have document.ready event, 
    // just take the function part and replace here. 
    // Not with document.ready 
    $(element).slideUp(1000, method, callback});

    $(element).slideUp({
                   duration: 1000, 
                   easing: method, 
                   complete: callback});
}

or try with add_endRequest event handler:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitialiseSettings)

Update

Better move the all the code from document.ready to InitialiseSettings function and pass it to pageLoaded event

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(InitialiseSettings)

Code Example:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(InitialiseSettings)
Comments