Suggestion: UpdateProgress with delay

Last post 08-08-2006 5:51 PM by Luis Abreu. 7 replies.

Sort Posts:

  • Suggestion: UpdateProgress with delay

    08-04-2006, 2:05 AM
    • Member
      365 point Member
    • dblock
    • Member since 12-06-2005, 5:33 PM
    • New York
    • Posts 95

    It would be pretty to have an UpdateProgress implement a delay. For example, anything executing under 1 second would not show the update progress panel. Anything longer than that shows it.

    Is this implementable?

    -dB.

    dB. - www.dblock.org / www.foodcandy.com
  • Re: Suggestion: UpdateProgress with delay

    08-04-2006, 11:48 AM
    • Member
      560 point Member
    • SimpleCoder
    • Member since 03-25-2006, 5:02 PM
    • Tribe of the 12 Planet
    • Posts 112
    that makes more sense.
    Sean Batson ACP
    WebSite
    5 out of 4 people have trouble with fractions
    Knowledge without Experience is like walking on pointed glass with paper shoes
  • Re: Suggestion: UpdateProgress with delay

    08-05-2006, 1:40 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    well, i'd say that it might be...you'll just need to write the javascript code that makes that happen (using a timer should help in getting the notification with little effort).

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Suggestion: UpdateProgress with delay

    08-06-2006, 1:03 PM
    • Member
      560 point Member
    • SimpleCoder
    • Member since 03-25-2006, 5:02 PM
    • Tribe of the 12 Planet
    • Posts 112

    ok luis

    do it.

    Sean Batson ACP
    WebSite
    5 out of 4 people have trouble with fractions
    Knowledge without Experience is like walking on pointed glass with paper shoes
  • Re: Suggestion: UpdateProgress with delay

    08-07-2006, 9:55 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    yes, i will! you'll have to wait more than usual since i'm on vacations, but i think that building a client behavior that handles this scneario shouldn't be very difficult...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Suggestion: UpdateProgress with delay

    08-07-2006, 10:32 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello again.

    well, i guess that you couldn't go into the pool without writing something to get you started. as i siad, this is a client behavior that can be applied to a control. it's very similar to the updateprogress code, but i've built it as behavior for 2 reasons: 1st, i'm a believer in that AJAS is client side; 2nd, because i think that transforming it into a server side component won't be too difficult (and this time I won't transform it so good luck). as allways, this code is as is and expect no support for it from me. having said that. here's page with the demo code:

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        void h(object s, EventArgs a)
        {
            System.Threading.Thread.Sleep(3000);
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <atlas:ScriptManager runat="server" id="manager" enablepartialrendering="true" />
            <atlas:updatepanel runat="server" id="panel">
                <contenttemplate>
                    <span>Partial postback:</span>
                    <%= DateTime.Now.ToString() %>
                    <asp:Button runat="server" ID="bt" Text="partial postback" OnClick="h" />
                </contenttemplate>
            </atlas:updatepanel>
            <div id="info">
                We're on a postback!
            </div>
           
            <script type="text/javascript">
                Type.registerNamespace( "LA.ATLAS" );
               
                LA.ATLAS.ProgressBehavior = function(){
                    LA.ATLAS.ProgressBehavior.initializeBase( this );
                   
                    var _timer;
                    var _timerInterval = 1000;
                    var _timerHandler;
                    var _loadHandler;
                    var _propertyHandler;
                   
                    this.get_timerInterval = function(){
                        return _timerInterval;
                    }
                   
                    this.set_timerInterval = function( value ){
                        _timerInterval = value;                   
                    }
                   
                    this.getDescriptor = function(){
                        var td = LA.ATLAS.ProgressBehavior.callBaseMethod( this, "getDescriptor" );
                        td.addProperty( "timerInterval", Number );
                        return td;
                    }
                   
                    this.initialize = function(){
                        LA.ATLAS.ProgressBehavior.callBaseMethod( this, "initialize" );
                       
                       this.control.element.style.display = "none";
                       
                        //handle load event
                        _propertyHandler = Function.createDelegate( this, this._onPropChanged );
                        _loadHandler     = Function.createDelegate( this, this._onLoadComplete );
                        Sys.Application.load.add( _loadHandler );
                       
                        //create timer
                        _timerHandler = Function.createDelegate( this, this._onTimerTick );
                        _timer        = new Sys.Timer();
                        _timer.set_interval( _timerInterval );
                        _timer.tick.add( _timerHandler );
                        _timer.set_enabled( false );
                    }
                   
                    this.dispose = function(){
                        if( _timer ){
                            _timer.tick.remove( _timerHandler );
                            _timer.set_enabled( false );
                            _timer.dispose();
                        }
                       
                        Sys.Application.load.remove( _loadHandler );
                       
                        if( $object("_PageRequestManager") ){
                            $object("_PageRequestManager").propertyChanged.remove( _propertyHandler );
                        }  
                       
                        _timerHandler = null;
                        _loadHandler = null;
                        _propertyHandler = null;
                       
                        LA.ATLAS.ProgressBehavior. callBaseMethod( this, "dispose" );
                    }
                   
                    this._onLoadComplete = function( obj, args ){                   
                        $object("_PageRequestManager").propertyChanged.add( _propertyHandler );
                    }
                   
                    this._onTimerTick = function( obj, args ){
                        this.control.element.style.display =  "";
                        _timer.set_enabled( false );
                    }
                   
                    this._onPropChanged = function( obj, args ){
                        if( args.get_propertyName() == "inPostBack" ){
                            if( $object("_PageRequestManager").get_inPostBack() ){
                                _timer.set_enabled( true );
                            }
                            else{
                                _timer.set_enabled(false);
                                this.control.element.style.display = "none";
                            }
                        }
                    }
                }
                LA.ATLAS.ProgressBehavior.registerSealedClass( "LA.ATLAS.ProgressBehavior", Sys.UI.Behavior );
                Sys.TypeDescriptor.addType( "script", "progressBehavior", LA.ATLAS.ProgressBehavior );
            </script>
          
        </form>
    </body>
    </html>
         <script type="text/xml-script">
                <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
                    <components>
                        <control id="info">
                            <behaviors>
                                <progressBehavior timerInterval="2000" />
                            </behaviors>
                        </control>
                    </components>
                </page>
            </script>

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Suggestion: UpdateProgress with delay

    08-08-2006, 6:47 AM
    • Member
      93 point Member
    • henrikholle
    • Member since 03-11-2006, 9:57 AM
    • Germany
    • Posts 22

    thank you for the great behavior Luis.

    regards

    henrik

  • Re: Suggestion: UpdateProgress with delay

    08-08-2006, 5:51 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    thanks!

    btw, if anyone wants to build an extender which encapsulates this behavior, please do it

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (8 items)