Tuesday, 15 February 2011

asp.net - how to keep javascripts after UpdatePanel partial postback -



asp.net - how to keep javascripts after UpdatePanel partial postback -

there lot of code want explain issue shortly in words. have master page, includes references javascript files , have pages utilize master page. utilize update panel in pages , within update panel there forms including one-has postback capability(ie dropdownlist). problem when state changes , partial postback occurs, forms has capabilities , effects because of javascripts, lose functionality. help appreciated.

this because after partial post update panel need re-initialize javascript. here general example

<script type="text/javascript"> // if utilize jquery, can load them when dom read. $(document).ready(function () { var prm = sys.webforms.pagerequestmanager.getinstance(); prm.add_initializerequest(initializerequest); prm.add_endrequest(endrequest); // place here first init }); function initializerequest(sender, args) { } function endrequest(sender, args) { // after update occur on updatepanel re-init need } </script>

relative questions: asp.net updatepanel in gridview jquery datepicker how id update panel initial request in javascript

after net 4 can simple utilize pageload function, similar onload function, handled asp.net , called on first page load, called after each ajax update.

function pageload() { // init here javascript // called when page load first time // , called 1 time again each time have update within updatepanel }

reference: http://msdn.microsoft.com/en-us/library/bb386417(v=vs.100).aspx

asp.net updatepanel ajaxcontroltoolkit

No comments:

Post a Comment