Monday, October 08, 2007

Providing Google like "Processing........" status

If you wanted to provide status bar for your pages as in Google.
you cab use below code to achieve the same.
Scnario:
1.Currently you are on Page1(start.aspx).Your post back leads you to Page2(End.aspx)
2.End.aspx is taking a while to load, so you want to show some status as in shown in Gmail.

Below screen shot will explain the same in detail.
Start.aspx


In Code behind file of Start.aspx button click event handler looks like this.

public void BtnClick(object sender, System.EventArgs e)
{
// Write your code here
string url = "Inter.aspx?target=End.aspx";
HttpContext.Current.Response.Redirect(url);
}



Inter.aspx just consist simple mesage as below.


Inter.aspx.cs looks like below.
public class Inter : System.Web.UI.Page
{
protected HtmlGenericControl bd;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
HtmlGenericControl body = (HtmlGenericControl)Page.FindControl("bd");
if (body != null)
{
body.Attributes["onload"] = GetAutoRedirectScript();
}

}

public string GetAutoRedirectScript()
{
return String.Format("location.href='{0}';", "End.aspx");

}
}

6 comments:

Anonymous said...

I implemented this and found amazing.
Thanks for the post.

Chandu said...

It'sa excellent solution surendra.thank you very much

Anonymous said...

Sounds interesting and Good article.
-john

Ashish said...

Very Good ....

Anonymous said...

What's up, yeah this article is really pleasant and I have learned lot of things from it concerning blogging. thanks.

Also visit my web page - Leanspa acai

Anonymous said...

Your style is unique compared to other people I've read stuff from. Many thanks for posting when you've got the opportunity, Guess I'll just book mark this blog.

Feel free to surf to my site; Saffron Extract Diet