Sean Aitken
Sean Aitken

Reputation: 1207

How do I temporarily convert an ASP.NET Ajax form to not use partial page updates?

I need the ability to temporarily turn off the partial page update behavior for an ASP.NET Ajax / UpdatePanel based page. (The reason is to circumvent the issue where IE blocks "automatic file downloads" for downloads generated as a result of this postback, but I don't want to distract from my original question)

I looked at the client side javascript libraries hoping to find a switch somewhere. I think a solution might involve using javascript to override the 'onclick' event handler for the control that acts as the trigger, and then calling "submit" on the form itself..

Also, using the EnablePartialRendering property on the server-side ScriptManager control won't work because that is done when the page is being built. I need to be able to do this as a result of switching a drop down list box.

Any ideas?

Cheers!

/ Sean

Upvotes: 0

Views: 163

Answers (2)

Sean Aitken
Sean Aitken

Reputation: 1207

Well, after much trial and error, I found two approaches that seemed to work:

  • Use Javascript to manually submit the top level form associated with the page. This usually has the ID of "form1".
  • Create a button that is outside of any UpdatePanels and use Javascript to click the button.

I wound up using the second approach, since it allowed me to handle the event with a specific routine without the need to guess that my postback came from a Javascript call.

This is an example of the code that performed the postback:

...
if (isDownload) {
    document.getElementById('FullPostbackSubmitter').click();
    return;
}
...

Hope this helps someone else!

Upvotes: 1

Atanas Korchev
Atanas Korchev

Reputation: 30671

You can set the EnablePartialRendering property of your ScriptManager to false.

Upvotes: 0

Related Questions