The Artima Developer Community
Sponsored Link

.NET Buzz Forum
A refresh button for asp.net pages

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
A refresh button for asp.net pages Posted: May 18, 2006 3:06 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter van Ooijen.
Original Post: A refresh button for asp.net pages
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement

Your browser has a back, forward and refresh button. Some time ago I wrote a little post on a back button to include on your own asp.net pages. According to the feedback you liked that one. Here I would like to share a refresh button. Quite simple but it works well!

You work with this code just like the back-button. This is the code

using System;

using System.Collections.Generic;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

 

namespace WebControlLibrary

{

   /// <summary>

    /// Summary description for MyRefreshButton.

    /// </summary>

    [ToolboxData("<{0}:MyRefreshButton runat=server></{0}:MyRefreshButton>")]

    public class MyRefreshButton : System.Web.UI.WebControls.LinkButton

    {

        protected override void OnClick(EventArgs e)

        {

            base.OnClick(e);

            Page.Response.Redirect(Page.Request.Url.ToString(), true);

        }

 

    }

Also this one is a descendent of the linkbutton. When it's clicked it redirects the response to the url of the page itself. Which will start a new series of roundtrips. Your page will have it's initial state again.

The actual behavior is not quite the same as that of the browser's refresh buttonn

  • Before issuing the redirect any click handlers are invoked in the base.OnClick(). In there you could do some things to save work.
  • Due to the way the page lifecycle works pageload and other eventhandlers will be executed before the redirect. Using the browser button these will not fire. The page prerender will not fire.

Hope you like it

Share this post: Email it! | bookmark it! | digg it! | reddit!

Read: A refresh button for asp.net pages

Topic: Expression Web Designer Community Technology Preview Download Previous Topic   Next Topic Topic: Office 2007 Client & MOSS 2007 Training

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use