Yesterday I wrote a little post on a refresh button for asp.net pages. It worked but had jump through some hoops. To simulate a refresh it posted back to the original page which in turn redirected itself to itself. Which is a waste of resources. As Simone pointed out it should simpler; like a straight link out of the browser. He's right. I will use a server side hyperlink as that gives me the possibility to fiddle with its properties on the server.
This refresh button works just like the back button, this one sets it's url to that of the page itself.
[ToolboxData("<{0}:MyRefreshLink runat=server></{0}:MyRefreshLink>")]
public class MyRefreshLink : HyperLink
{
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack)
base.NavigateUrl = Page.Request.Url.ToString();
base.OnLoad(e);
}
[Browsable(false)]
public new string NavigateUrl
{
get
{
return base.NavigateUrl;
}
}
}
In the back button post are instruction how to use the control in your projects.
Hope you'll like this one better.