Saturday, March 24, 2012

Call a client JavaScript function after each and every AJAX callback

Hi,

I have a DropDownList, which is enabled or disabled depending on the state of a CheckBox. I am doing this in JavaScript. I have a function which checks the state of the CheckBox, and sets the DropDownList as either enabled or disabled accordingly. I have attached a call to this function to the 'OnClick' attribute of the CheckBox so it gets called each time the CheckBox is used.

All of this is in an UpdatePanel, along with some other functionality which is not directly related. The problem I am having is that each time there is a Postback to the server (or rather I should say a Callback, as we are in an UpdatePanel), the DropDownList is changed to enabled, even if it was disabled before the Callback.

I thought an easy way to solve this would be to call my 'Disable the DropDownList according to the state of the CheckBox' function after each Callback.

So... how can I set my page to call a JavaScript function after each Callback?

Thanks...

Hi,

I'm using this for that task:

function pageLoad( )
{
Sys.WebForms.PageRequestManager.getInstance( ).add_pageLoaded( PageLoadedHandler );
}

function PageLoadedHandler( sender, args )
{
// your code
}

Check ASP.NET AJAX Client Life-Cycle Events for what is pageLoad, also seepageLoaded Event from the same page.



Thanks very much - that is exactly what I needed. I think I need to get down to it and start exploring the whole Sys.WebForms namespace properly.

Thanks again for your help - I'm very grateful.

No comments:

Post a Comment