Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you should know is that you cannot check the status of a file upload using the standard FileUpload control. What you can do is to upload the file on the server and then connect to it using ODBC and start reading and inserting lines in your database asynchronous (by making a ajax request to a page or using a script service).</p> <p>As far as the progress bar goes, you should simply use a CSS progres bar (you can find a simple example at: <a href="http://css-tricks.com/examples/ProgressBars/" rel="nofollow">http://css-tricks.com/examples/ProgressBars/</a>).</p> <p>Then, you should build a script service (using a web serivice) with a method that can return the status of your progress from the server:</p> <p>Your *.asmx file should contain something like:</p> <pre><code>[WebMethod] public int GetStatus() { int progress = 0; // in percents // your server-side code here return progress; } </code></pre> <p>Your aspx page should contain something like:</p> <pre><code>&lt;asp:ScriptManager runat="server" ID="ScriptManager"&gt; &lt;Services&gt; &lt;asp:ServiceReference Path="~/services/import.asmx" InlineScript="false" /&gt; &lt;/Services&gt; &lt;/asp:ScriptManager&gt; </code></pre> <p>Then, you should be able to call that method from JavaScript periodically (each second for example, using setTimeout) and update the progress bar width with simple JavaScript or jQuery:</p> <pre><code>var tout, service; function UpdateStatus() { if (tout != null) clearTimeout(tout); if (service == null) service = new namespace.here.serice_class_here(); service.GetStatus(onSuccess, onFailure); } function onSuccess(result) { // update the width of the progress with result (the integer value of the progress) progress_bar.style.width = percent + "%"; // call the method again tout = setTimeout("UpdateStatus()", 1000); } function onFailure(error) { alert(error.get_message()); } </code></pre> <p>You could extend your onSuccess JavaScript function and when the progress is complete (returned value is 100%) you could redirect the user to another page or display an info or a button depending on your needs.</p> <p>I hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload