jQuery Script is not executing after a button click in update panel
I have a button inside a update panel, & I am using jQuery scripting to style the elements in the page. Initially the page loads & css style applies on it along with the script which have some jQuery code. i.e. Initially everything is OK. But when I click on the button it causes a server post-back(necessary), the CSS style is applied but Script is not loade开发者_StackOverflow社区d. Please help me out with this.
Add this to your script (if using .Net 3.5 or less). It will notify the Microsoft Ajax Library that the JavaScript file has been loaded.
if (typeof (Sys) != 'undefined')
{
Sys.Application.notifyScriptLoaded();
}
Note: This is obsolete in .Net 4
You need to run your code (best as a named function) as part of the endRequest
event as well, for example you can have a named function like this:
function doStuff() {
//do whatever here
}
Then run that function where needed:
//run on DOM ready
$(doStuff);
//also run it when UpadtePanels finish/reload
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(doStuff);
精彩评论