I am not very skilled in ASP.NET and I have tried to:
- Update UI elements on an aspx site
- at the same time download a file
I have this JS function:
function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader',
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.src = url;
};
and this Button server control:
<asp:Button runat="server" ID="Button1" Content="DOWNLOAD" OnClick="Button1_Click" />
in the EventHandler I simply call:
// UPDATE UI
textBoxXY.Text = "Text after file download";
ClientScript.RegisterStartupScript(typeof(MyPage), "myDownloadKey", "downloadURL(" + ResolveUrl("~/MyDownloadHandler.ashx") + ");", true);
What do you think of this approach. It seems to work but...