C# ASP.NET Detect Download - c#

I am maintaining a website written in C# with ASP.NET. At the bottom of a page is an iframe. When a user clicks a button, the source for that iframe is set with Javascript to a page on the server.
showLoadWidget();
document.getElementById("downloadFrame").src='SdrTrendDownload.aspx';
return false;
That page generates a file and allows the user to download it. Once the download file box pops up, I want to call hideLoadWidget() so the 'Loading Data...' overlay goes away. How do I detect when the download file box pops up?

You can't detect that in addition this get more complicated depending on their security setting for the zone detected for your site
I will suggest that you just wrap the call inside updatepanel and use the partial postback to trigger the download prompt and progress template for displaying the loading widget. Let .net and the browser deal with it.

You can't, much less the browsers (like Chrome) who actually don't pop open a download file dialog. What you should probably do is simply attach to the 'ready' or 'loaded' event on the page and hide the widget when that event occurs.

Tejs is correct. IE 9 doesn't do a modal dialog anymore either. What you can do is set up a download progress watcher and programmatically hide the overlay once the watcher sees data is being sent to the client.

Can you use a hidden HTML form element reporting a DOM event such as onload or onfocus? I set some of these hidden fields in formmail.php from tectite.com, which sends email from a page to a mailbox on the server.

Well, I don't think you can do that. "The Download File Box" is a browser feature. What you should do is call the hideLoadWidget() right after you call the download.

Related

Blazor File Download - How to show loading animation for CTA?

I have a "download file" button component in Blazor that when clicked, it calls an endpoint that returns a FileStream. The FileStream is then downloaded to the browser via JSInterop.
All of this works great. But if it's a big file, there's no clear indication or feedback that clicking the button has done anything. I assume that because my button is a call-to-action rather than a hyperlink, the browser has no native way of knowing to display the "Waiting..." animation like when clicking on a hyperlink.
Is my only choice to implement a custom spinner animation?

How can I open a webpage first and then fill in text boxes and click a button and visibly view the results?

[edit] It is a requirement that the webpage spawn and open in IE and allow user manual interaction after the programmatic actions have completed.[/edit]
I've seen a lot of code examples online about opening webpages or filling in webpage textboxes and getting a return value without ever opening them visibly.
I would like to open a webpage in IE, fill in a few textbox buttons
and then click the submit button and view the results visibly.
I am able to do this with a dll called Selenium, but I do not want to use a 3rd party application and it seems that WebBrowser() should be able to do this?
I can post my failed code examples if that would help.
Thanks.
Maybe this qould fit better as a comment, but I don't have enoigh reputation.
Do you know how HTTP-Forms work?
It would probably be easier to send a HTTP-Request to the target of the form you want to fill, including the parameters you would like to fill into the form.
So you don't need any WebBrowser or similar, just a simple HttpWebRequest object, where you specity the target, the method (very likely POST) and the data you'd like to send.
You can use the webbrowser control in Winforms. It is possible to access every DOM object of the website using the control. No need to open the IE externally.
You just need to specify the webbrowser URL as your link.
Then, fill the textboxes with code,
BrowserID.Document.GetElementById("TextboxID").SetAttribute("Value", "NewVaue")
Also, you can click on the button using InvokeMember("click").
There are lots of stuff using WebBrowser. You can learn it here.

How to download a scrollable HTML page

I would like to download a webpage from tumblr, so I can scrub it from the images -
https://www.tumblr.com/tagged/otto_schmidt
However (once your logged in), the page continues to load images, as you scroll down further.
What's the best way to download the page in C# so you can scrub it?
You can you winform webbrowser control, fire document loading complete event.
Hope this help!

Supress show download dialog box in webbrowser

I use webbrowser to show web page. I have link which I must click to show other control. But problem is that this click execute download dialog box which I don't need.
It is way to block showing dialog only for moment?
In order to avoid it you need to turn off the auto download box on internet explorer--Security settings.

Integrate Moneybookers into WPF applications

I would like to integrate moneybookers payment-gateway into a WPF-application. Accroding to the official gateway manual I need to redirect the user to the moneybookers payment-page and submit some fields posted within an html-form.
Has anyone an idea how I could solve this task?
Best regards!
Yes, all you need to do is:
Include a Frame control in your WPF application.
Include a .html file in your WPF application that contains a element with the appropriate data and some JavaScript to automatically post the form when the page is loaded.
When it is time for payment, have your display the Frame control and set its Url to the relative path of the .html file.
When the user is done paying you can give them a button to close the Frame yourself, or you can subscribe to the Navigated event on the Frame and when the payment processor causes them to navigate back to your fake HTML you can automatically close the Frame and use your own WPF UI to tell them "congratulations, thanks for paying".

Categories

Resources