A refresh button for asp.net pages

I was reading a post A refresh button for asp.net pages by Peter Van Ooijen, and I am not sure if I agree with the implementation suggested by Peter in the article to refresh the page. It seems unnecessarily requires two server trips just to refresh the same page. It can, instead, easily be done with a single trip.

IMO, we can achieve page refresh action by just adding onclick attribute to the button.

HyperLink1.Attributes.Add("onclick", "document.Form1.submit();");

Or, if you want a fresh instance of that page after refresh then add this script to onclick event instead.

HyperLink1.Attributes.Add("onclick", "document.location='" + Request.Url.ToString() + "'");

One thought on “A refresh button for asp.net pages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s