简体   繁体   English

按钮单击到上一页asp.net

[英]Button click to previous page asp.net

I am know some .Net basic but i need to do more advanced thing and I am stuck. 我知道一些.Net basic,但是我需要做更多高级的事情,所以我被困住了。 I have empClientProfile.aspx page access to this page possible from different places (from list of clients, direct from menu and other.) I want to put button by pressing which it will redirect user on exact same page as he/she was before. 我有empClientProfile.aspx页面,可以从不同位置(从客户端列表,直接从菜单等)访问此页面。我想按下按钮,以将用户重定向到与之前完全相同的页面。 For example if client doing select from agencies it should forward to exact same page with that select. 例如,如果客户从代理商处进行选择,则应转发到与该选择完全相同的页面。 If this page was accessed from main menu it should forward to home menu. 如果从主菜单访问此页面,则应转到主菜单。

Using PostBackURL doesn't work here because as I said page can be reached from different pages. 使用PostBackURL在这里不起作用,因为正如我所说,可以从其他页面访问页面。

Any Ideas how to do it? 有什么想法怎么做?

Use the following button code in your HTML 在HTML中使用以下按钮代码

<input type="button" value="Back" onclick="window.history.back()" />

UPDATE 更新

Try these files and test it out... 尝试这些文件并进行测试...

filename: page1.htm 文件名:page1.htm

<html>
  <head>
    <title>page 1</title>
  </head>
  <body>
    PAGE 1<br />
    <a href="page2.htm">Jump to page 2</a><br />
    <a href="page3.htm">Jump to page 3</a><br />
  </body>
</html>

filename: page2.htm 文件名:page2.htm

<html>
  <head>
    <title>page 2</title>
  </head>
  <body>
    PAGE 2<br />
    <a href="page3.htm">Jump to page 3</a><br />
    <input type="button" value="Back" onclick="window.history.back()" />
  </body>
</html>

filename: page3.htm 文件名:page3.htm

<html>
  <head>
    <title>page 3</title>
  </head>
  <body>
    PAGE 3<br />
    <a href="page1.htm">Jump to page 1</a><br />
    <input type="button" value="Back" onclick="window.history.back()" />
  </body>
</html>

maybe u can use session to do it based on user action 也许您可以根据用户操作使用会话来完成

switch(action)
{
case 1:
   postbackurl = Session[a].toString();
case 2:
   postbackurl = Session[b].toString();
default:
   break;

}

您是否尝试过Request.UrlReferrer?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM