Custom AJAX in ASP.NET 1.1

Last post 05-09-2008 4:01 AM by blodfox777. 4 replies.

Sort Posts:

  • Custom AJAX in ASP.NET 1.1

    05-08-2008, 5:11 AM
    • Loading...
    • juzuking
    • Joined on 11-15-2002, 3:52 AM
    • Posts 146

    I needed a way of using ajax effects in asp.net 1.1 so I'm trying to display an image when a user clicks a search button.

    I have javascript to display the div (which displays 'please wait.....') when the button is clicked, then I'm using javascript to open a new page in a new window with the search results.

     The problem I have is that when I click the button, 'please wait..' appears, then the new page opens, it is still loading and goes to  the background, but the div 'please wait...' does not display on the origional page any more.

     Is there any way of keeping the div displaying untill the other page has fully loaded and focused?

    Hope this makes sense, if not please let me know!

    Mark

  • Re: Custom AJAX in ASP.NET 1.1

    05-08-2008, 9:48 AM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 7:33 PM
    • Posts 6,867
    • TrustedFriends-MVPs

    This seems to work for me (no AJAX):

    ParentWindow.aspx:

    <form id="Form1" method="post" runat="server">
     <input type="button" onclick="onButtonClick();" value="Open Window">
     <div id="messageDiv"></div>
    </form>

    <script type="text/javascript">
    <!--

    function onButtonClick()
    {
     document.getElementById('messageDiv').innerHTML = 'Please wait...';
     var uniqueId = 'NewWindow_' + new Date().getTime();
     var windowFeatures =
      'channelmode=no,directories=no,fullscreen=no,' +
      'location=no,dependent=yes,menubar=no,resizable=no,scrollbars=no,' +
      'status=no,toolbar=no,titlebar=no,' +
      'left=100,top=100,width=400px,height=200px';
     windowRef = window.open('WebForm2.aspx', uniqueId, windowFeatures);
     window.focus();
    }
    // -->
    </script>

    ChildWindow.aspx

    <script type="text/javascript">
    <!--
    window.onload = function ()
    {
     window.focus();
    }
    // -->
    </script>

    But the best way to do this that I have found is to forget about the parent window and just use this little Custom Control that I posted a while back in the child window http://forums.asp.net/1108609/ShowPost.aspx

    NC...

  • Re: Custom AJAX in ASP.NET 1.1

    05-08-2008, 10:11 PM
    • Loading...
    • blodfox777
    • Joined on 07-12-2007, 8:30 AM
    • Posts 40

    Hi juzuking

    I suppose there is another way to display 'Page Loading...' div, try the following code, hope this helpsSmile:

    <html>    
         <head>    
         <title></title>    
         <script type="text/javascript">    
             var url = 'http://www.google.co.uk/search?hl=en&q=asp.net&meta='; //the details page you want to display... 
         </script>    
         <style>    
             .loading-indicator {    
                 font-size:8pt;    
                 background-image:url(../images/loading/loading.gif);    
                 background-repeat: no-repeat;      
                 background-position:top left;    
                 padding-left:20px;    
                 height:18px;    
                 text-align:left;    
             }    
             #loading{    
                 position:absolute;    
                 left:45%;    
                 top:40%;    
                 border:3px solid #B2D0F7;    
                 background:white url(../images/loading/block-bg.gif) repeat-x;    
                 padding:10px;    
                 font:bold 14px verdana,tahoma,helvetica;    
                 color:#003366;    
                 width:180px;    
                 text-align:center;    
             }    
         </style>    
         <div id="loading">    
             <div class="loading-indicator">    
                 Page Loading...    
             </div>    
         </div>    
         </head>    
         <body onload="location.href = url;" style="overflow:hidden;overflow-y:hidden">    
         </body>    
         <script>    
            if(document.layers) {    
                 document.write('<Layer src="' + url + '" visibility="hide"></Layer>');    
             }    
            else if(document.all || document.getElementById) {    
                 document.write('<iframe src="' + url + '" style="visibility:hidden;"></iframe>');    
             }    
            else {    
                 location.href = url;    
             }    
         </script>    
    </html>
     
    Regards!
    Lance
    -- "Mark As Answer" If my reply helped you --
  • Re: Custom AJAX in ASP.NET 1.1

    05-09-2008, 3:10 AM
    • Loading...
    • juzuking
    • Joined on 11-15-2002, 3:52 AM
    • Posts 146

    Hi blodfox777,

    Thanks for your help so far. Your example is great, but rather re-directing using the same page, is there a way I can open a new window with google in once its loaded?

    Thanks again for your help, 

    Mark

  • Re: Custom AJAX in ASP.NET 1.1

    05-09-2008, 4:01 AM
    • Loading...
    • blodfox777
    • Joined on 07-12-2007, 8:30 AM
    • Posts 40

    Hi  juzuking

    hope this helpsSmile:

    /////////////////////////////Main.htm//////////////////////////////

    <html>
    <head>
        <title></title>
    
        <script type="text/javascript">    
            function hide(targetid){
                if (document.getElementById){
                    target=document.getElementById(targetid);
                            target.style.display="none";
                }
            }
    
            function show(targetid){
                if (document.getElementById){
                    target=document.getElementById(targetid);
                            target.style.display="block";
                }
            }
        </script>
    
        <style>
            #loading
            {
                position: absolute;
                left: 45%;
                top: 40%;
                border: 3px solid #B2D0F7;
                background: white url(../images/loading/block-bg.gif) repeat-x;
                padding: 10px;
                font: bold 14px verdana,tahoma,helvetica;
                color: #003366;
                width: 180px;
                text-align: center;
                display: none;
            }
        </style>
    </head>
    <body>
        <input type="button" value="Open" onclick="show('loading');winRef=window.open('Result.htm');winRef.focus();" />
        <div id="loading">
            Page Loading...
        </div>
    </body>
    </html>
     

    /////////////////////////////Result.htm//////////////////////////////

     

    <html>    
         <head>    
         <title>search result</title>    
         </head>    
         <body onload="window.opener.hide('loading');">    //may be another event will better, not onload, but sorry I have forgotten
    
         </body>    
     </html>
    
     
    Regards!
    Lance
    -- "Mark As Answer" If my reply helped you --
Page 1 of 1 (5 items)