浏览器后退按钮创建问题

发布于 2024-08-15 04:49:37 字数 697 浏览 2 评论 0原文

我在页面上有一个动态生成的网格视图,后面的代码中也提供了排序。 现在我使用链接从页面 A 移动到页面 B,这也很好用。 但是当我按下浏览器后退按钮并返回到我的页面 A 并再次尝试排序...页面 A 抛出异常...

有没有一种方法可以像我们通常编程按钮一样对该后退按钮进行编程..

谢谢

` 找不到列机器名。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

 Exception Details: System.IndexOutOfRangeException: Cannot find column machinename.

Source Error:

Line 519:                
Line 520:                //Sort the data.
Line 521:                dt.DefaultView.Sort = e.SortExpression + " " +       GetSortDirection(e.SortExpression);
Line 522:                GridView1.DataSource = Session["TaskTable"];
Line 523:                GridView1.DataBind();`

I have a dynamically generated gridview on page with sorting provided in the code behind also.
Now i move from page A to page B using a link, this also works fine.
But when i press the browser back button and come back to my page A and again try to sort... page A throws an exception...

is there a way to program this back button like we program a button normally..

Thanks

` Cannot find column machinename.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.IndexOutOfRangeException: Cannot find column machinename.

Source Error:

Line 519:                
Line 520:                //Sort the data.
Line 521:                dt.DefaultView.Sort = e.SortExpression + " " +       GetSortDirection(e.SortExpression);
Line 522:                GridView1.DataSource = Session["TaskTable"];
Line 523:                GridView1.DataBind();`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煞人兵器 2024-08-22 04:49:37

页面 A 可能已缓存在您的浏览器中。单击返回时您将获得此缓存版本。尝试强制浏览器不将页面缓存在(页面 A 的)后面的代码中:

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now - new TimeSpan(1, 0, 0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false);

Page A is probably cached in your browser. You get this cached version when clicking back. Try forcing the browser not to cache the page in the the code behind (of page A) with:

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now - new TimeSpan(1, 0, 0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文