User cancels the Upload Progress

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

User cancels the Upload Progress

Guest-33

Hi,

i have a small problem here.

After i canceled the upload progress by pressing the "cancel button" implemented, i cant use my buttons for redirecting to other ASPX Pages.

It is a simple button with an Eventhandler and the command/instruction line: Server.Transfer("anyotherpage.aspx");

If i press the button, nothing happens, it just happens right after i canceled the upload.

Someone know how to workaround it ? (Right now, i just close the browser...)

Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Dean Brettle
Administrator
Hi,

What browser is this occuring in?  Does the problem go away if you wait for a few seconds after clicking the cancel button before clicking your other buttons? If so, perhaps the upload hasn't actually been stopped yet and the browser is ignoring clicks on other buttons until it has stopped.  Not sure, just a theory... 

Also, do you see the same problem if you click the browsers Stop button instead of NeatUpload's cancel button?  When you click the cancel button, javascript is executed which is suppose to simulate clicking the browser's Stop button. 

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Guest-33

Hi,

this happens with IE, Mozilla and Netscape.

The problem still happens if i wait a few seconds or use the "stop" button from the browsers.

I tested this with big files because small files uploading too fast before i can cancel it.

This happens on local PC and with PCs over Internet too.

Does this happen to you too ? Can u implement Link-Buttons to switch to other pages within the project if u would use them on the "Upload Page" ?

Maybe you are using a different way to redirect to other pages within the project ?

 

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Dean Brettle
Administrator
Are you using LinkButtons or regular Buttons?  NeatUpload 1.0.12 doesn't support LinkButtons, but the latest development snapshot (NeatUpload-trunk.95.zip) does.  If you just want links that take the user to other pages (but not actually submit the form), in NeatUpload-1.0.12  you should be able to use regular <asp:HyperLink> elements or plain HTML <a> elements.  The live demo uses the latter for the link to the NeatUpload home page. 

If you decide to use LinkButtons with the latest development snapshot, you will want to list them as NonUploadButtons if you don't want the file uploaded when they are clicked.  See the manual that accompanies the dev snapshot for details on non-upload buttons.

If you aren't using LinkButtons, can you send me (dean at brettle dot com) the aspx/aspx.cs files you are using so I can try to reproduce?

Thanks,

--Dean

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Guest-33

Im using regular Buttons with a link to a ASPX Page within the project.

I will send you example files.

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Jason

Your E-Mail mailer demon seems to refuse zip files, so i just uploaded it to my Web Server. More details coming with a E-Mail.

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Dean Brettle
Administrator
Got the files.  FYI, my mail goes through gmail which refuses zip files containing exes.

I'm not going to be able to test the files personally for a little while because I'm having problems with my Mono installation at the moment.  However, I did look over them and I think I know what the problem is.  When you click the redirect button, the browser is submitting the form including the large file.  The file takes a long time to upload but no progress bar is displayed/started because you didn't call progressBar.AddTrigger(Test_Redirect).  So, it looks like the button isn't working, but in fact you will get redirected if you wait long enough for the file to upload.

To test this theory, time how long it takes to upload the file without cancelling, then try to reproduce the problem but wait the same amount of time to see if you get redirected.  Alternatively, after cancelling the upload, clear the filename before clicking the redirect button.

The solution to the problem is to either use a regular link instead of the button, or use the development snapshot and list the redirect button as a NonUploadButton.  In the latter case, NeatUpload will generate javascript to automatically clear the filename when you click the redirect button.

Let me know if that doesn't solve the problem.

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Jason

Hi Dean,

thanks again for your effort.

I tested what u have mentioned and the button will work if i wait the same amount of time like the upload usually takes to complete with a big file. (approx. 1 min.)

Unfortunately i cant use a regular link coz my project is protected with Web.Security and a session working on it.

So i need to clear the filename if the link "button" will be clicked.

You know a "simple" way to clear the filename without implementing the snapshot version with NonUploadButton for now ?

Or if it doesnt make too much work, can u plz tell me what kind of Javascript commands i need for it ?

Thanks a lot.

 

Jason

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Dean Brettle
Administrator
Hi Jason,

Are you sure you can't use a regular link?  If the session id is maintained with a cookie, I think the session will be maintained as long as you are redirecting within the same domain.  If the session id is maintained in the URL (aka cookie-less session), using a relative URL should still work.

Regardless, to clear the filename when the user clicks the redirect button, you can try adding the following javascript function to your page:

<script language="javascript"><!--
function NeatUpload_ClearFileInputs(elem)
{
    var inputFiles = elem.getElementsByTagName('input');
    for (var i=0; i < inputFiles.length; i++ )
    {
        var inputFile = inputFiles.item(i);
        if (inputFile.type == 'file')
        {
            var newInputFile = document.createElement('input');
            for (var a=0; a < inputFile.attributes.length; a++)
            {
                var attr = inputFile.attributes.item(a);
                if (attr.specified && attr.name != 'type' && attr.name != 'value')
                    newInputFile.setAttribute(attr.name, attr.value);
            }
            newInputFile.setAttribute('type', 'file');
            inputFile.parentNode.replaceChild(newInputFile, inputFile);
        }
    }
}
--></script>

and then call it from your redirect button like this:

<asp:Button id="Test_Redirect" onclick="NeatUpload_ClearFileInputs(document.getElementById('uploadForm'))" runat="server" Text="Test_Redirect"></asp:Button>

If that doesn't do the trick, the best I can recommend is using the development snapshot.  FWIW, switching should be relatively painless, will result in cleaner code, and will get you other nice features like AJAX-style refresh-less updating of the progress bar.

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Jason

Hi Dean,

thanks for the code.

Unfortunately the Javascript doesnt work, i inserted it direct in the "html part" of the aspx page, compiled it successfully and if i click the button it just says some strange error message that i got to much characters in the string literal and points to this line:

<asp:Button id="Test_Redirect" onclick="NeatUpload_ClearFileInputs(document.getElementById('uploadForm'))" runat="server" Text="Test_Redirect"></asp:Button>

Nevertheless, i got everything working now coz i modified the way im using my sessions and simply used a "hyperlink" element for it.

Thanks for your help.

Jason

Reply | Threaded
Open this post in threaded view
|

Re: User cancels the Upload Progress

Dean Brettle
Administrator
Glad you found a solution.  Sorry about the bad code.  Looks like in <asp:Button> elements the "onclick" attribute is suppose to name a server-side method, not javascript like it does in <input type="submit"> elements.

--Dean

PS.  Thanks for mentioning NeatUpload on your blog and home page!