简体   繁体   中英

Preloading page between two asp.net pages

I posed a question that related where I could display "Page loading" in asp.net page using jQuery. But, I had no luck.

So, say I have page1 and it navigates to page2 and page2 doesn't some heavy data access. Is there any way I could show the "preloading" page while the page2 is finished.

I want to navigate from Page1 -> "Preload" -> Page2(once page2 is completed).

I want to know if this is possible using Javascript in the code behind.

Thanks.

The way you would typically do this is have a page that shows the message and uses AJAX, in my example using jQuery, to load the other page onto the current page.

<body>
   <div id="content">
   Page loading
   </div>

   <script type="text/javascript">
        $(function() {
            $('#content').load('/url/to/other/page');
        });
   </script>
</body>

I've omitted loading jQuery itself.

Note: you could do this on a single page by having it generate different content based on some query parameter. You don't need to actually have a separate "loading" page -- though you could probably make that work for several different pages as well.

If using JavaScript is OK, redirect the user to the Preload page, and then use JavaScript to take the user to Page2. This will make the Preload page stay visible while Page2 is loading.

(Also, "JavaScript in the codebehind"? Don't tell me you're using JScript.NET or something as your server side language)

No matter what you do, to begin loading Page2 you'll have to navigate away from Page1 (unless you get complicated and wrap your pages in another container on a single page and navigate within your container).

Otherwise the default content for Page2 should be a "Preloading" message that gets taken away once the document has finished loading its content.

Is a possible solution to have an almost empty page with a few placeholder divs in the right places containing a loading image. Then run web service calls to populate each placeholder in jquery/javascript?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM