Welcome Guest Search | Active Topics | Sign In | Register

Download the file using the progress bar Options
armstrong
Posted: Tuesday, April 8, 2014 9:56:17 PM
Rank: Newbie
Groups: Member

Joined: 4/8/2014
Posts: 0
Hi

a short question:
How can I download the file using the progress bar?

Code: HTML/ASPX
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>

    <script type="text/javascript" src="<%=this.ResolveUrl("~/Scripts/jquery-1.9.1.min.js") %>"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            
            var pb = eo_GetObject('<%=ProgressBar1.ClientID %>');
            if (null != pb) {
                pb.startTask();

            }

        });
        

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>

        <eo:ProgressBar ID="ProgressBar1" runat="server" BorderColor="Black" BorderWidth="1px"
            Height="16px" IndicatorColor="LightBlue" Value="0" ControlSkinID="None" BorderStyle="Solid"
            Width="300px" ShowPercentage="true" StartTaskButton="btnStart" StopTaskButton="btnStop" OnRunTask="ProgressBar1_RunTask">
        </eo:ProgressBar>
    <br/>
    <asp:LinkButton id="btnStart" runat="server">Start</asp:LinkButton>
      
    <asp:LinkButton id="btnStop" runat="server">Stop</asp:LinkButton>

        <eo:Downloader runat="server" ID="Downloader1" DownloadButtonID="Button1" DirectLinkLabelID="Label1" DynamicContent="True" OnDownload="Downloader1_Download"></eo:Downloader>
    <asp:Label runat="server" ID="Label1"></asp:Label>
    <asp:Button Runat="server" ID="Button1" Text="Generate File &amp; Download"></asp:Button>

    </div>
    </form>
</body>
</html>



Code: C#
public static MemoryStream aa = new MemoryStream();

protected void ProgressBar1_RunTask(object sender, EO.Web.ProgressTaskEventArgs e)
{
        e.UpdateProgress(0);

        aa = Report(e);//Execute other function 

        Downloader1_Download(object sender, EO.Web.DownloadEventArgs e);//How can i call download event?

        e.UpdateProgress(100);

}

protected class ContentGenerator : EO.Web.DynamicDownloadContent
{
        protected override void GenerateContent()
        {
            SetFileName("test.PDF", -1);
            byte[] buffer = aa.GetBuffer();           
            Write(buffer, 0, buffer.Length);
        }
}

protected void Downloader1_Download(object sender, EO.Web.DownloadEventArgs e)
{
        NameValueCollection args = new NameValueCollection();
        e.DynamicDownload(typeof(ContentGenerator), args);

}

protected MemoryStream Report(EO.Web.DownloadEventArgs e)
{
        MemoryStream ms = new MemoryStream();

        for (int i = 0; i < 100; i++)
        {
            if (e.IsStopped)
                break;
            
            other();//Execute other function 

            e.UpdateProgress(i);
        }

        return ms;
}


Thanks for your help ^^.
eo_support
Posted: Wednesday, April 9, 2014 3:39:04 AM
Rank: Administration
Groups: Administration

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

You can take a look of this sample:

http://demo.essentialobjects.com/Demos/Progress%20Bar/Server%20Side%20Task%20-%20Advanced%202/Demo.aspx

This sample demonstrates how to trigger another task after your ProgressBar is done. In the sample, the code calls setTimeout to call eo_Callback. In your case, you would want to call setTimeout to call Downloader.Start function:

http://www.essentialobjects.com/doc/1/jsdoc.public.downloader.start.aspx

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!


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.