http://www.codeproject.com/Tips/583469/MVC-Different-Redirection-Techniques-Razor
This tip lists different redirection techniques for MVC4.
- HTML TagHide Copy Code
<input type="button" value="Forgot Password" onclick="window.location.href('@Url.Action("ForgotPassword","Account")')" />
- For posting, you could use a
form
:Hide Copy Code<form method="post" id="signin" action="@Url.Action("ForgotPassword", "Account")"> <input type="button" value="Forgot Password" /> </form>
- Using script:Hide Copy Code
<script type="text/javascript"> $(document).ready(function () { $('#btnForgotPassword').click(function (e) { location.href = '@Url.Content("~/Account/ForgotPassword/")'; }); }); </script>
- If it is a link:Hide Copy Code
@Html.ActionLink("some text", "actionName", "controllerName")
- For posting, use a form:Hide Copy Code
@ using(Html.BeginForm("actionName", "controllerName")) { <input type="submit" value="Some text" /> }
- For Anchor Tag:Hide Copy Code
<a href="http://www.codeproject.com/Controller/View" class="Button">Text</a>
- Using
RenderAction
:Hide Copy Code@{ Html.RenderAction("ActionName", "ControllerName", new { FranchiseSetId = Model.FranchiseSetID }); }
No comments:
Post a Comment