ASp.net c# sql

April 20, 2010

Back button refresh page

There are situation wherein you need to reload the page/control state after browser’s “Back” button is pressed.

For example: If you have a checkbox, If someone clicks on checkbox  postback and selectedindexchange/checkedchange event is fired. Once browser’s back button is pressed, page is refreshed but still the checkbox is checked.

Below is the solution for this.

protected override void OnInit(EventArgs e)

    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
        Response.Cache.SetExpires(DateTime.MinValue);

        base.OnInit(e);
    }
Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com. Fonts on this blog.

Follow

Get every new post delivered to your Inbox.