views:

45

answers:

2

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

A: 

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

korchev
I was vague in my original post. This won't work because it can only be changed before the Page_Init(...) is called. I need to make the switch at "run time", from Javascript. Thanks tho! :)
CleverCoder
A: 

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!

CleverCoder