javascript - Call a function after every updatepanels partial postback event, on the page -


i working on custom control being used on webpage contains many updatepanels. in custom control, there extensive use of jquery , many plugins used well. now, on every updatepanel's postback, control gets rendered again , again, loads javascript resources again too, doesnt call javascript functions again. causing problem many elements in control has turned in 1 thing or jquery plugin not working(javascript functions not calling in simple).

now have tried many solutions, including ones mentioned in question how have javascript callback executed after update panel postback? in vain. previously, when page contained 1 updatepanel,

pageload(sender, args); 

functon working fine, in case of multiple updatepanels not working, neither

var prm = sys.webforms.pagerequestmanager.getinstance(); prm.add_pageloaded(pageloaded);  function pageloaded() { } 

if don't want control refresh on every updatepanel's postback - set updatemode updatepanel hosts control conditional way refreshed when own trigger or child control fire (ref: http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.updatemode(v=vs.90).aspx).

that said, don't have manually add pageloaded event handler on client side. use intristic pageload function fires on every page load via updatepanel or otherwise (ref: http://msdn.microsoft.com/en-us/library/bb386417(v=vs.90).aspx)

one other way fire js function server-side code. every time control loads or performs server-side init - use clientscript.registerstartupscript call make sure js function called on client afterward, example

clientscript.registerstartupscript(this.gettype(),"myfunc", "myfunction();", true); 

ref: http://msdn.microsoft.com/en-us/library/z9h4dk8y(v=vs.90).aspx


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -