Monday, January 12, 2015

Create Loading page in between two pages

Assuming that after login success in Login.aspx, it redirects to Data.aspx which takes 1 minute for loading page. In such case, user will see that Login page will be frozen for that 1 minute loading time. So. the idea is that we need to have one page to interactive with user that data is loading.

>>> Login.aspx

After logged in, redirect to Loading.aspx instead of Data.aspx


>>> Loading.aspx

Add id and runat attribute in body tag
<body id="body" runat="server">
Loading Data...
</body>

Add following code snipped in Page_Load event.
string myScript = @"<script language='javascript' type='text/javascript'>
                                function Redirect() {
                                window.location = '";
        myScript += "Data.aspx";
        myScript += "';}</script>";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Wait", myScript);
        body.Attributes.Add("onload", "Redirect();");

That's it. Enjoy programming. !!!

No comments:

Post a Comment