.net - ASP.NET AJAX Progress Bar: Update from Code Behind? -


I have an import function for Excel spreadsheets inside an application. I currently use FileUpload control. I upload the file, then run an operation on that file. I want to inform the user of the operation being done, and the percentage which is done. I think I can take the number of total rows extracted from the Excel spreadsheet, and split it continuously because I incorporate each record into the database and update the progress bar.

The problem is that I can not find any solutions that can update a progress bar from behind the code. I tried to experiment.

It's great to see, but I can not see it to work from behind the code. Theoretically, I thought that to put value in a text box on the page, and changing the JavaScript function to set a set would work as a percentage, but I did not even get the desired results Given.

Any suggestions as to how this can be done?

What you should know is that you upload the file using the standard file upload control Can not check. What you can do is upload that file to the server and then connect it using the ODBC and start reading and inserting your database asynchronous (using an AJAX request or a script service on one page) lines.

As far as progress progresses, you should just use the CSS Progger Bar (you can find a simple example on this).

Then, you should make a script service (using web services) with a method that can return the status of your progress to the server:

Your * .asmx file should contain something like this:

  [WebMethod] Public InkGetStatus () {int progress = 0; // percents // your server side code return here; }  

Your aspx page should contain something like this:

  & asp: ScriptManager runat = "server" id = "ScriptManager" & gt; & Lt; Services & gt; & Lt; Asp: ServiceReference path = "~ / services / import.asmx" inline script = "wrong" /> & Lt; / Services & gt; & Lt; / ASP: ScriptManager & gt;  

Then, you should be able to call that method from time to time (for example, each set using seconds, setTimeout) and progress bar with simple javascript or jQuery Update Width:

  Worth Tout, Service; Function updatestats () {if (tout! = Null) empty timeout (tout); If (service == zero) service = new namespace .here.serice_class_here (); Service. Gatestats (onsoot, on fuel); } Success on function (results) {// progress of progress with progress of progress (integer value of progress) progress_bar.style.width = percentage + "%"; // Tout method again = setTimeout ("UpdateStatus ()", 1000); } Failure on function (error) {warning (error.get_message ()); }  

You can extend your onsite javascript function and when the progress is complete (the returned value is 100%), you can redirect the user to another page or your Depending on the information, a button or button can be displayed.

I hope it helps!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -