开发者

Buggy behavior when redirecting from a RowCommand Event?

开发者 https://www.devze.com 2023-03-15 22:16 出处:网络
One of my columns in the GridView is a开发者_如何学Go CommandField button called \"ViewProfile\".

One of my columns in the GridView is a开发者_如何学Go CommandField button called "ViewProfile".

The event handler, "MyGridView_RowCommand(...) ", redirects to another page "ViewUserProfile.aspx" when the "ViewProfile" button is clicked.

After clicking "ViewProfile" and being redirected to "UserProfile.aspx", I press the back button.

Now that I'm back on "ViewUsers.aspx", I click any other button which is NOT part of the grid view.

HERE's the buggy part... The "MyGridView_RowCommand(...)", event fires with an event argument that indicates the "ViewProfile" button was clicked! Yes. When returning the page (after the redirect) clicking any button not inside the GridView somehow causes a RowCommand event to be raised. The odd behavior continues until I refresh the browser.

Anyone know of a way to fix this?


I would guess that a cached version was loaded. You could disable caching for this page:

in Page_Load:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

or via adding this meta-tag to your aspx-page:

<meta http-equiv="pragma" content="no-cache" />

or via adding the window.onbeforeunload event to the aspx-page:

window.onbeforeunload = function () {
   // This function does nothing.  It won't spawn a confirmation dialog
   // But it will ensure that the page is not cached by the browser.
}
0

精彩评论

暂无评论...
验证码 换一张
取 消