Loading dialog...

Last post 02-21-2008 7:34 AM by zopostyle. 8 replies.

Sort Posts:

  • Loading dialog...

    02-20-2008, 12:11 PM
    • Member
      36 point Member
    • zopostyle
    • Member since 02-03-2006, 11:06 AM
    • Posts 67

    Hi,

    I'm using ajax in .net 3.5, and is there a way to in our updatepanelprogress put a "loading message" that scrolls with the screen ??? just like the one from MagicAjax ?

    Can you give me an example...

    Thanks

    --
    Domain hosting http://brunozp.com.br
    Visit: http://brunozp.com
  • Re: Loading dialog...

    02-20-2008, 12:24 PM
    Answer

    The key is just to use fixed positioning. 

                    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                        <ProgressTemplate>
                            <div style="position: fixed; top: 200px; left: 200px;">
                                Please wait.
                            </div>
                        </ProgressTemplate>
                    </asp:UpdateProgress> 
     
    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: Loading dialog...

    02-20-2008, 12:56 PM
    • Member
      36 point Member
    • zopostyle
    • Member since 02-03-2006, 11:06 AM
    • Posts 67

    No I think that I was not clear, this does not solve my problem, cause it will be fixed at the place of the page that I put the HTML...

    What I need is a box that keeps on the top right corner of the screen, over anything that is on the page...But with something that make it float at the screen if the user scroll down the scroll bar....

    I'm using this code...but it's missing the scroll event...

     

    <div id="tipDiv" style="text-align:center;vertical-align:middle;Z-INDEX: 100px; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 20%; HEIGHT: 100%;">
        <table width="50%" height="50%" align="center">
         <tr>
          <td valign="middle" align="center">
           <b><font size="2">Loading...</font></b><br /><img src="../loading.gif">
          </td>
         </tr>
        </table>
     </div>
    
     
    --
    Domain hosting http://brunozp.com.br
    Visit: http://brunozp.com
  • Re: Loading dialog...

    02-20-2008, 1:48 PM

    No, that is not what fixed position does.  Fixed positioning is where it appears in relation to the screen, irregardless of the scrolling of the page.  If I give something the CSS of  style="position:fixed; top: 0px; right: 0px;", it will remain at the top right, no matter how far I scroll down the rest of the content.

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: Loading dialog...

    02-20-2008, 2:10 PM
    • Member
      36 point Member
    • zopostyle
    • Member since 02-03-2006, 11:06 AM
    • Posts 67

    OK, so if you were right this should work...

     

    <html>
    <head>
    <title>Nova pagina 1</title>
    </head>
    <body>
    asdasda
    <p>asfds</p>
    <p>as</p>
    <p>f</p>
    <p>sd</p>
    <p>as</p>
    <p>f</p>
    <p>asdf</p>
    <p>as</p>
    <p>dfg</p>
    <p>asg</p>
    <p>as</p>
    <p>fg</p>
    <p>sfgh</p>
    <p>adf</p>
    <p>ha</p>
    <p>dgh</p>
    <p>adg</p>
    <p>jagj</p>
    <p>q</p>
    <p>e5ujw</p>
    <p>euy</p>
    <p>3y</p>
    <p>4q5</p>
    <p>y4</p>
    <p>q</p>
    <p>h4</p>
    <p>h5</p>
    <p>q45h</p>
    <p>q4</p>
    <p>5egh</p>
    <p>b</p>
    <p>b</p>
    <p>dfbs</p>
    <div style="position:fixed; top: 0px; right: 0px;">
    TESTEEEEEEEEEEEEEEEEEEEEEEE
    </div>
    </body>
    </html>
     But it's not...
    --
    Domain hosting http://brunozp.com.br
    Visit: http://brunozp.com
  • Re: Loading dialog...

    02-20-2008, 2:17 PM
    Answer

    You need a DOCTYPE declaration at the very top of your document.  Insert the following before the <html> tag and magically everything will work.

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

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: Loading dialog...

    02-20-2008, 4:09 PM
    Answer
    • Contributor
      2,422 point Contributor
    • kirchi
    • Member since 03-07-2007, 7:47 AM
    • Posts 328

    Hi zopostyle,

    I use the following approach:

    1) Place the following html in a page:

    <div id="pnlPopup" class="PrProgress" style="display:none;">

    <div id="innerPopup" class="PrContainer">

    <div class="PrHeader">Loading, please wait...</div>

    <div class="PrBody">

    <img width="220px" height="19px" src="images/activity.gif" alt="loading..." />

    </div>

    </div>

    </div>

     

    On the same page register for ajax events:

    <script type="text/javascript">

    Sys.Application.add_load(applicationLoadHandler);

    Sys.Application.add_unload(applicationUnloadHandler);

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);

    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandler);

    </script>

    Create js file with following contents:

     

    function applicationLoadHandler() {
        /// <summary>Raised after all scripts have been loaded and the objects in the application have been created and initialized.</summary>
    };
    function applicationUnloadHandler() {
        mainForm.CleanUp();
        mainForm = null;
        Sys.Application.dispose();
    };
    function beginRequestHandler() {
        /// <summary>Raised after an asynchronous postback is finished and control has been returned to the browser.</summary>
        mainForm.StartUpdating();
    };
    function endRequestHandler() {
        /// <summary>Raised before processing of an asynchronous postback starts and the postback request is sent to the server.</summary>
        // Set status bar text if any was passed through the hidden field on the form
        mainForm.EndUpdating()
    };
    var mainForm = 
    {
        pnlPopup : "pnlPopup",
        innerPopup : "innerPopup",
        activityImg : null,
        updating : false
    };
    mainForm.StartUpdating = function() {
        mainForm.updating = true;
        mainForm.AttachPopup();
        mainForm.onUpdating();
    };
    mainForm.EndUpdating = function() {
        mainForm.updating = false;
        mainForm.DetachPopup();
        mainForm.onUpdated();
    };
    mainForm.onUpdating = function(){
        if(mainForm.updating) {
            var pnlPopup = $get(this.pnlPopup);
            pnlPopup.style.display = '';	    
            var docBounds = mainForm.GetClientBounds();
            var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup);
            var x = docBounds.x + Math.round(docBounds.width / 2) - Math.round(pnlPopupBounds.width / 2);
            var y = docBounds.y + Math.round(docBounds.height / 2) - Math.round(pnlPopupBounds.height / 2);	    
            Sys.UI.DomElement.setLocation(pnlPopup, x, y);
            //if(Sys.Browser.agent == Sys.Browser.InternetExplorer) {
                if(!pnlPopup.iFrame) {
                    var iFrame = document.createElement("IFRAME");
                    iFrame.scrolling= "no";
                    iFrame.src = "nothing.txt";
                    iFrame.frameBorder = 0;
                    iFrame.style.display = "none";
                    iFrame.style.position = "absolute";
                    iFrame.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
                    iFrame.style.zIndex = 1;
                    pnlPopup.parentNode.insertBefore(iFrame, pnlPopup);
                    pnlPopup.iFrame = iFrame;
                } 
                pnlPopup.iFrame.style.width = docBounds.width + "px";
                pnlPopup.iFrame.style.height = docBounds.height + "px";
                pnlPopup.iFrame.style.left = docBounds.x + "px";
                pnlPopup.iFrame.style.top = docBounds.y + "px";
                pnlPopup.iFrame.style.display = "block";      
            //}  
        }           
    }
    mainForm.onUpdated = function() {
        // get the update progress div
        var pnlPopup = $get(this.pnlPopup);
        // make it invisible
        pnlPopup.style.display = 'none';
        if(pnlPopup.iFrame) {
            pnlPopup.iFrame.style.display = "none";
        }
    }; 
    mainForm.AttachPopup = function() {
        /// <summary>
        /// Attach the event handlers for the popup
        /// </summary>
        this._scrollHandler = Function.createDelegate(this, this.onUpdating);
        this._resizeHandler = Function.createDelegate(this, this.onUpdating);    
        $addHandler(window, 'resize', this._resizeHandler);
        $addHandler(window, 'scroll', this._scrollHandler);
        this._windowHandlersAttached = true;
    };
    mainForm.DetachPopup = function() {
        /// <summary>
        /// Detach the event handlers for the popup
        /// </summary>
        if (this._windowHandlersAttached) {
            if (this._scrollHandler) {
                $removeHandler(window, 'scroll', this._scrollHandler);
            }
            if (this._resizeHandler) {
                $removeHandler(window, 'resize', this._resizeHandler);
            }
            this._scrollHandler = null;
            this._resizeHandler = null;
            this._windowHandlersAttached = false;
        }
    };
    mainForm.CleanUp = function() {
        /// <summary>
        /// CleanUp all resources held by mainForm object
        /// </summary>
        this.DetachPopup();
        var pnlPopup = $get(this.pnlPopup);
        if(pnlPopup && pnlPopup.iFrame) {
           pnlPopup.parentNode.removeChild(pnlPopup.iFrame);
           pnlPopup.iFrame = null;
        }
        this._scrollHandler = null;
        this._resizeHandler = null;
        this.pnlPopup = null;
        this.innerPopup = null;
        this.activityImg = null;
        this.updating = null;
    };
    if(typeof(Sys) !== "undefined")Sys.Application.notifyScriptLoaded();

     

    Now what it does - it centeres the progress dialog in the center of the cscreen and maintains its position even if user tryies to scroll the screen horizontally or vertically,

    thats not all - this progress blocks all interactions of user with any of elements on the screen by placing the transparent iframe on the screen.

     

    Hope this helps

    My blog: http://blog.devarchive.net
    My samples: http://devarchive.net
  • Re: Loading dialog...

    02-21-2008, 7:34 AM
    • Member
      36 point Member
    • zopostyle
    • Member since 02-03-2006, 11:06 AM
    • Posts 67

    Thanks it worked...

    I had a lot of html problem for the others component layout...but it's ok..

     Thanks

    --
    Domain hosting http://brunozp.com.br
    Visit: http://brunozp.com
Page 1 of 1 (9 items)