Saturday, March 1, 2008

How to trigger a full postback from within an AJAX UpdatePanel

If you've ever used an AJAX UpdatePanel and needed to have a control within the UpdatePanel cause a full postback of the page, here's how you do it.

ScriptManager scriptManager = ScriptManager.GetCurrent(Page);

if (scriptManager != null)

{

    scriptManager.RegisterPostBackControl(SaveButton);

}

First you have to get access to the ScriptManager on the page.  Then you register the control within the UpdatePanel that needs to trigger a full postback.

4 comments:

Anonymous said...

Thanks!

Nixus said...

Thanks very helpful!

Anonymous said...

But this will always cause a full postback, even when the page is being validated.

Is there another way to do this?

Anonymous said...

Thanks. This was VERY helpful!