Progressbar code behind

  1. #1

    Progressbar code behind

    Hello,

    I want to try something out: On the examples page there is an example of a progressbar.

    [default.aspx]

    <script type="text/javascript">
            var updateBar = function(value, pbar, btn, count, callback) {
                if (value > count) {
                    btn.setDisabled(false);
                    callback();
                } else {
                    pbar.updateProgress(value / count, 'Loading item ' + value + ' of ' + count + '...');
                }
            }
    
            var run = function(pbar, btn, count, callback) {
                btn.setDisabled(true);
                var ms = 5000 / count;
                for (var i = 1; i < (count + 2); i++) {
                    setTimeout(updateBar.createCallback(i, pbar, btn, count, callback), i * ms);
                }
            }
    
            var runProgress1 = function(status, progress, btn) {
                status.setText('Working');
                progress.show();
                run(progress, btn, 10, function() {
                    progress.reset(true);
                    status.setText('Done.');
                });
            }
        </script>
    
    <body>
        <form id="batchGUI" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <br />
        <p>
            <b>1. Basic Progress Bar</b><br />
            Dynamic show/hide and built-in progress text:
            <ext:Button ID="ShowProgress1" runat="server" Text="Show">
                <Listeners>
                    <Click Handler="runProgress1(#{StatusLabel}, #{Progress1}, this);" />
                </Listeners>
            </ext:Button>
            <br />
            <ext:Label ID="StatusLabel" runat="server" Cls="status" Text="Nothing to see here." />
            <ext:ProgressBar ID="Progress1" runat="server" Width="300" Text="Initializing..."
                Hidden="true" />
        </p>
        </form>
    </body>
    -------------------------------------------------------------------------------------------------------------------------------------

    But now I want an EQUIVALANT version of this in code behind.
    This is my guess:

    [default.aspx.cs]

    [DirectMethod]
            public void runProgress1(Ext.Net.Label status, Ext.Net.ProgressBar progress, Ext.Net.Button btn)
            {
                status.Set("Working2", status);
                progress.Show();
                run(progress, btn, 10, function()   // What to do with this? function does  not exist in current context
                {
                    progress.Reset(true);
                    status.Set("Done.", status);
                });
            }
    
            [DirectMethod]
            public void run(Ext.Net.ProgressBar pbar, Ext.Net.Button btn, int count, callback)
            {
                btn.Disabled = true;
                 var ms = 5000 / count;
    
                for (var i = 1; i < (count + 2); i++) 
                {
                    
                    setTimeout(updateBar.createCallback(i, pbar, btn, count, callback), i * ms);    // setTimeout does not exist in current context.
                }
            }
    
            [DirectMethod]
            public void updateBar(int value, Ext.Net.ProgressBar pbar, Ext.Net.Button btn, int count, callback)
            {
                if (value > count) 
                {
                    btn.Disabled = false;
                    callback();      // callback() does not exist in the current context
                } 
                else 
                {
                    pbar.UpdateProgress((value / count), "Loading item " + value + " of " + count + "...");
                }
            }
    PS: as for why I want codebehind is because instead of (var ms = 5000 / count) I need to use my own code. That's for every succesful method called on object X, e.g. if method "add" is success then int success++ something like this.
    Last edited by HaamSapTjai; Feb 13, 2012 at 2:15 PM.

Similar Threads

  1. [CLOSED] ProgressBar Server Side Update
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: May 31, 2017, 12:59 AM
  2. [CLOSED] Progressbar implementation issue
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 27, 2011, 5:21 PM
  3. [URGENT] How to add Progressbar to Ext:Column
    By shakeebgenii in forum 1.x Help
    Replies: 0
    Last Post: Apr 16, 2010, 3:57 AM
  4. [CLOSED] ProgressBar in Panel
    By Steve in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 18, 2009, 8:48 PM
  5. ProgressBar inside rows of GridPanel : Possible ?
    By jeybonnet in forum 1.x Help
    Replies: 0
    Last Post: Jan 07, 2009, 12:01 PM

Tags for this Thread

Posting Permissions