Welcome Guest Search | Active Topics | Sign In | Register

Downloader Options
Brad Coble
Posted: Wednesday, January 20, 2010 8:18:16 AM
Rank: Advanced Member
Groups: Member

Joined: 2/4/2009
Posts: 31
Hi!

Is there a way via code to cancel a dynamic download?

Here is my class to send a file. I want to check if the file exists, and if not, I want to cancel the download and report the problem to the user.

I dont see a way to do this. It seems to cancel the download, but leaves the user with a cryptic message inside the popup window.

Thanks!!

Brad


Code: C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.Specialized;
using System.Web.Configuration;
using System.IO;

/// <summary>
/// Summary description for ControlsFileDownloader
/// </summary>
public class ControlsFileDownloader : EO.Web.DynamicDownloadContent
{  
    public ControlsFileDownloader() { }

    protected override void GenerateContent()
    {
        string folderName = WebConfigurationManager.AppSettings["ControlFileLocation"].ToString();
        string fileName = folderName + Arguments["fileName"] + "." + Arguments["fileId"];

        if ( File.Exists( fileName ) )
            WriteFile( fileName, Arguments["fileName"] );       
    }
}
eo_support
Posted: Wednesday, January 20, 2010 9:01:40 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can perform checks inside the Downloader's Download event right before you call e.DynamicDownload. Once you are inside GenerateContent, then it's already too late.

Thanks!
Brad Coble
Posted: Wednesday, January 20, 2010 9:05:13 AM
Rank: Advanced Member
Groups: Member

Joined: 2/4/2009
Posts: 31
Doh!

I have placed my file checking code within the download event and dont call the DynamicDownload method unless the file exists, however, the popup seems to still appear. It seems to be waiting on something. It can be closed.

How can I prevent it from showing at all?

Thanks!
eo_support
Posted: Wednesday, January 20, 2010 2:14:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The popup will always open but it will automatically close if you don't actually start the download. There is no way for you to prevent it from showing unless you want to do the check before you show user the downloader.

Thanks!

Brad Coble
Posted: Wednesday, January 20, 2010 3:12:48 PM
Rank: Advanced Member
Groups: Member

Joined: 2/4/2009
Posts: 31
Strange, it is not closing for me. Could it be because I am usng a callback?

Code: HTML/ASPX
<eo:Callback ID="dl_cbp" runat="server" Triggers="{ControlID:Downloader1;Parameter"></eo:Callback>

<asp:Button ID="Button1" runat="server" Text="Get File"  />

<eo:Downloader OnDownload="Downloader1_Download" ID="Downloader1" runat="server"
                                DownloadButtonID="Button1" AutoHideDownloadButton="False" ClientSideOnDownload="dlgMain_Cancel"
                                DynamicContent="True" >
                            </eo:Downloader>


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.