Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemController:Controller
- {
- public ActionResult Login(int id)
- {
- return View("Hi", id);
- }
- }
- Html.ActionLink(article.Title, new { controller = "Articles", action = "Details", id = article.ArticleID })
- Html.ActionLink(article.Title,
- "Login", // <-- Controller Name.
- "Item", // <-- ActionMethod
- new { id = article.ArticleID }, // <-- Route arguments.
- null // <-- htmlArguments .. which are none. You need this value
- // otherwise you call the WRONG method ...
- // (refer to comments, below).
- )
- public static string ActionLink(this HtmlHelper htmlHelper,
- string linkText,
- string controllerName,
- string actionName,
- object values,
- object htmlAttributes)
- Html.ActionLink(article.Title,
- "Item", // <-- ActionMethod
- "Login", // <-- Controller Name.
- new { id = article.ArticleID }, // <-- Route arguments.
- null // <-- htmlArguments .. which are none. You need this value
- // otherwise you call the WRONG method ...
- // (refer to comments, below).
- )
- public static string ActionLink(this HtmlHelper htmlHelper,
- string linkText,
- string actionName,
- string controllerName,
- object values,
- object htmlAttributes)
- Html.ActionLink(article.Title,
- "Item", // <-- ActionMethod
- "Login", // <-- Controller Name.
- new { article.ArticleID }, // <-- Route arguments.
- null // <-- htmlArguments .. which are none. You need this value
- // otherwise you call the WRONG method ...
- // (refer to comments, below).
- )
- <a href="/Item/Login/5">Title</a>
- routes.MapRoute(
- "Default", // Route name
- "{controller}/{action}/{id}", // URL with parameters
- new { controller = "Home", action = "Index", id = "" } // Parameter defaults
- );
- Html.ActionLink(article.Title,
- "Login", // <-- ActionMethod
- "Item", // <-- Controller Name
- new { id = article.ArticleID }, // <-- Route arguments.
- null // <-- htmlArguments .. which are none
- )
- <%=Html.ActionLink("Get Involved",
- "Show",
- "Home",
- new
- {
- id = "GetInvolved"
- },
- new {
- @class = "menuitem",
- id = "menu_getinvolved"
- }
- )%>
- Html.ActionLink(article.Title, "Login/" + article.ArticleID, 'Item")
Add Comment
Please, Sign In to add comment