How to run client script after postback?

I'm looking for something like OnClientClick for a button, but I want this to happen after the postback (not before). I am currently using the following which works, but it adds the script block over and over, which is not what I want. I just want to execute an existing client script function.

ScriptManager.RegisterClientScriptBlock( 
  this, 
  typeof( MyList ), 
  "blah", 
  "DraggifyLists();", 
  true );

      

0


source to share


1 answer


If you are using ASP.NET AJAX you can try this:

addRequestHandler()

should be called when your page is loaded



function addRequestHandler()
{
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
}


function endRequestHandler(sender, args)
{
    // This function will be called after the postback has completed

    // add your JavaScript function call here
}

      

This is based on code from Disturbed Budda

+1


source







All Articles