views:

598

answers:

1

Hello,

Do you think it's possible to refresh an update panel and immediately after redirecting the response (for instance a download) ?

I tried this:

  • an invisible button -> as an asyncpostbacktrigger

  • a download button -> when it is clicked the onclientclick clicks the invisible button

  • the click event on the invisible button refreshes the update panel
  • then the download button click event launches the download (normal postback which launches the download)

However for some reason when the invisible button is clicked by the download button client script, it doesn't refresh the update panel..

Do you have an idea why it doesn't work? Or do you have other and cleaner techniques?

Here's how the elements are declared:

     <asp:Button runat="server" ID="ButtonInvisible" Text="" Click="RefreshDisplay" />

<asp:Button runat="server" ID="ButtonDownload" Text="Download" OnClientClick="clickInvisible(this.id)" Click="Download" /><Triggers>
                <asp:AsyncPostBackTrigger ControlID="ButtonInvisible" /></Triggers>

//the javascript
<script type="text/javascript" language="javascript">
function clickInvisible(idButton) {
    document.getElementById('ButtonInvisible').click();

}</script>

'

 //the methods 
Download(object source, EventArgs e){Response.Redirect("test.txt")}
RefreshDisplay(object source, EventArgs e){ ButtonCancel.Enabled = false;}
A: 

Is the RefleshDisplay only going to disable the ButtonCancel button? Then you can do it in plain JavaScript without using any trigger:

<asp:Button runat="server" ID="ButtonDownload" Text="Download" OnClientClick="disableCancelButton()" Click="Download" />

<script type="text/javascript" language="javascript">
function disableCancelButton() {
    document.getElementById('<%= ButtonCancel.ClientID %>').disabled = true;
}
</script>
awe
It's true but the control's viewstate won't be set to the correct value. So in the next postback state will be lost for this button.
teebot.be