views:

290

answers:

2

I have updatepanel with timer control that executes once (gets some images after initial page load)

How to register jquery plugin (interfade) on updatepanel postback (or better jquery js along with plugin)?

I prefer loading plugin after timed postback to reduce initial page size.

A: 

I think you could use the PageRequestManager Events to regsiter some js after an updatepanel postback.

http://msdn.microsoft.com/en-us/library/bb398976.aspx

For example, you could put a timer on your updatepanel and add something similar to the following client side:

function endRequestHandler(sender, args) {
    RegisterMyPlugin();
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);

Additionally, you can determine which panel/control caused the postback by inspecting the sender like this:

    function endRequestHandler(sender, args) {
        alert(sender._postBackSettings.panelID);
    }
brendan
ThanksOne more question: how to check in endRequestHandler if sender is updatepanel with ID="UpdatePanel1" ?
daniel
added info to the answer
brendan
A: 

Unlike $(document).ready which only gets called when the page first renders, if you create a function called pageLoad in client code on your page, it will get called each time a partial page back occurs (and on the initial page load) automatically by the ASP.NET framework. So, you can put client code in this function to set up your plugins.

AdamB