后退按钮或导航到特定视图(页)-APS.NET MVC3 [英] Back button or Navigate To Specific View(Page) -APS.NET MVC3

查看:201
本文介绍了后退按钮或导航到特定视图(页)-APS.NET MVC3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET MVC3我的Web应用程序。要显示在用户界面中的按钮,我用我View1.cshtml以下HTML。

I am using ASP.NET MVC3 for my web application. To display a button in the User Interface I am using the following html in my View1.cshtml.

   <div class="demo">
                    <input type="submit" value="Save" title="Click here to create a comment" />
                    <input type="button" value="Cancel" onclick="location.href='/'"  title="Click here to cancel and go back to main menu" />
 </div>

我要放置一个按钮,以便用户可以回到previous网页..因此,要实现这一点,我想放置一个按钮,这需要视图名称和.cshtml能

I want to place a button so that users can go back to the previous page.. So to achieve this I want to place a button in the .cshtml which takes View Name and can


  • 转移到特定视图。 (或)

  • 要在previous视图。

中的任何一个上面的要求,将有利于我的申请。

Any one above requirements will be good for my application.

我怎样才能做到这一点?任何帮助或想法将是有益的我。

How can I do this? Any help or ideas will be useful to me.

感谢您

推荐答案

如果您想给用户发送到他们的previous页面,您可以随时使用 Request.UrlReferrer 在你的控制器,但要注意,它可能为他们欺骗这很容易。另一种方法是将存储在会话中的previous位置的用户,那么你可以检索它并把它挂到该按钮,您的视图。

If you want to send the user to their previous page, you can always use Request.UrlReferrer in your controller, but beware that it's possible for them to spoof this quite easily. Another way would be to store the previous location in the session for the user, then you could retrieve it and hook it up to the button in your view.

对于想要一个按钮,看看这里:<一href=\"http://stackoverflow.com/questions/596444/html-actionlink-as-a-button-or-an-image-not-a-link/667834#667834\">Html.ActionLink作为一个按钮或图像,而不是一个链接

As for wanting a button, take a look here: Html.ActionLink as a button or an image, not a link

你要知道,是不是真的有必要增加一个后退按钮?大多数浏览器都内置其中的; - )

Mind you, is it really necessary to add a back button? Most browsers have them built in ;-)

这篇关于后退按钮或导航到特定视图(页)-APS.NET MVC3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆