确定回发打开一个新页面
我有一个带有 LinkButton 的页面(page1),单击该按钮会将浏览器带到新页面(page2)。
当我单击 LinkButton page1 时,会发回 page1 并点击 page1 的 Init 和 Load 事件处理程序,然后移至 page2。
我如何在 page1 回发中知道我将被带到一个新页面,而不是单击导致页面回发但不导航离开的按钮?
I have a page (page1) with a LinkButton that, when clicked, will take the browser to a new page (page2).
When I click the LinkButton page1 posts back and hits the Init and Load event handlers for page1, and then moves on to page2.
How can I tell in the page1 postback that I am about to be taken to a new page, as opposed to clicking a Button that causes the page posts back but does not navigate away?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以将 OnClick 事件添加到每个按钮的代码后面,如果要回发到另一页面,请执行 Response.Redirect。但其局限性在于,如果您需要“page2”上的表单数据,您将丢失 Response.Redirect 上发布的表单数据。
You can also add OnClick events to your code behind for each button, and in the case of the one that is to postback to another page, do a Response.Redirect. The limitation of that however is that if you need form data on "page2", you will lose posted form data on a Response.Redirect.
看来您没有使用LinkButton的OnCLick事件,如果您使用该事件,则执行单击那里的操作,而不是在Page Load事件上执行?
It appears that you're not using the OnCLick event of the LinkButton, If you use the event, perform the action of the click there, not on the Page Load event?