[CLOSED] TaskManager and FileUploadField don't work together correctly

  1. #1

    [CLOSED] TaskManager and FileUploadField don't work together correctly

    Hello,
    I want to use TaskManager and FileUploadField on the same page.
    Unfortunately the page reloads continuously and crashes und Chrome or Firefox.
    How can I do this?
    Thanks

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="DCx.DeltaConsoExpert.WebForm3" %>
    
    <%@ Import Namespace="System.Threading" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head id="Head1" runat="server">
        <title>ProgressBar - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        <script runat="server">
            protected void UploadClick(object sender, DirectEventArgs e)
            {
            }
    
            protected void StartLongAction(object sender, DirectEventArgs e)
            {
                this.Session["LongActionProgress"] = 0;
                ThreadPool.QueueUserWorkItem(LongAction);
    
                ResourceManager1.AddScript("{0}.startTask('longactionprogress');", TaskManager1.ClientID);
            }
    
            private void LongAction(object state)
            {
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(1000);
                    this.Session["LongActionProgress"] = i + 1;
                }
    
                this.Session.Remove("LongActionProgress");
            }
    
            protected void RefreshProgress(object sender, DirectEventArgs e)
            {
                object progress = this.Session["LongActionProgress"];
    
                if (progress != null)
                {
                    Progress1.UpdateProgress(((int)progress) / 10f, string.Format("Step {0} of {1}...", progress.ToString(), 10));
                }
                else
                {
                    ResourceManager1.AddScript("{0}.stopTask('longactionprogress');", TaskManager1.ClientID);
                    Progress1.UpdateProgress(1, "All finished!");
                }
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <h1>
            Progress Bar</h1>
        <p>
            The example shows how to update the ProgressBar during long server-side actions.</p>
        <ext:ProgressBar ID="Progress1" runat="server" Width="300" />
        <ext:TaskManager ID="TaskManager1" runat="server">
            <Tasks>
                <ext:Task TaskID="longactionprogress" Interval="1000" AutoRun="false">
                    <DirectEvents>
                        <Update OnEvent="RefreshProgress" />
                    </DirectEvents>
                </ext:Task>
            </Tasks>
        </ext:TaskManager>
        <ext:Panel ID="Form" runat="server" Width="600" Frame="true" AutoHeight="true" PaddingSummary="10px 10px 0 10px"
            LabelWidth="50" ButtonAlign="Center">
            <Items>
                <ext:FileUploadField ID="FileUploadField1" runat="server" AnchorHorizontal="100%"
                    EmptyText="Selectionner un fichier..." FieldLabel="Fichier" ButtonText="" Icon="ImageAdd">
                    <DirectEvents>
                        <FileSelected OnEvent="UploadClick" />
                    </DirectEvents>
                </ext:FileUploadField>
            </Items>
    
            <Buttons>
                <ext:Button ID="ImportButton" runat="server" Text="Importation">
                    <DirectEvents>
                        <Click OnEvent="StartLongAction" />
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Panel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Oct 14, 2011 at 10:11 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I tried this page under FF and it is not "crashed" for me, at least there is nothing that I can say "it's crashed".

    Generally speaking, "crashed" is not so informative. Errors, exceptions? A browser hangs up?

    Repeat myself, I can't reproduce any of these symptoms.
  3. #3
    I suggest to use Type="Load" for Update DirectEvent otherwise you will upload file with each request
    If Type="Load" then no form submit and you have to pass all required info manually as extra parameters
  4. #4
    Thanks for quick answer.
    The problem is that the whole page reload even with Type="Load" for Update DirectEvent.

    When I use the TaskManager without FileUpload only the TaskManager progress bar is updated

    When I use the TaskManager WITH FileUpload the TaskManager progress bar is updated (ok) and the page reloads continuously (not ok)
    Thanks
  5. #5
    Why do you think that page is reloaded?
    If FileUploadField is used then hidden iframe is used to submit a file.
    Base page is not reloaded but iframe is submitted
  6. #6
    Hi,
    You can test by clicking on "Importation" button. Look at IE progressBar, it shows that IE reload the whole page.
    When there is no FileUploadField in page, IE progressBar not appears (ok)
    Thanks
  7. #7
    It shows that iframe has been submiting (not that the page is reloading)
    If you set Type="Load" for Update direct event then task manager requests will not submit a file (file will be submitted when button is clicked only)
  8. #8

    [Solved]

    Cool, it works,
    So sorry I put Type="Load" in FileUploadField, which is wrong.

    Type="Load" should be put in the TaskManager and it works
    Thanks a lot for your help

        <ext:TaskManager ID="TaskManager1" runat="server">
            <Tasks>
                <ext:Task TaskID="longactionprogress" Interval="1000" AutoRun="false">
                    <DirectEvents>
                        <Update OnEvent="RefreshProgress" Type="Load" />
                    </DirectEvents>
                </ext:Task>
            </Tasks>
        </ext:TaskManager>
    Last edited by critt; Oct 14, 2011 at 10:01 AM. Reason: [CODE] tag

Similar Threads

  1. [CLOSED] FileUploadField doesn't work as should
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 23
    Last Post: Jul 16, 2012, 4:40 PM
  2. Replies: 2
    Last Post: Jun 19, 2012, 1:19 PM
  3. Replies: 7
    Last Post: Mar 28, 2011, 4:51 PM
  4. [CLOSED] TaskManager
    By majestic in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 12, 2009, 7:27 AM
  5. FileUploadField can't work
    By Fresh.Killer in forum 1.x Help
    Replies: 1
    Last Post: Dec 07, 2009, 8:26 AM

Tags for this Thread

Posting Permissions