Questions tagged [actionlink]

In ASP.NET MVC, the ActionLink method renders an element that links to an action method in a controller. Specifically, it returns an anchor element ( tag) that contains the virtual path of the specified action method (possibly with route parameters).

In ASP.NET MVC, the ActionLink method renders an element that links to an action method in a controller. Specifically, it returns an anchor element ( tag) that contains the virtual path of the specified action method (possibly with route parameters).

LinkExtensions.ActionLink Method
http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink.aspx

605 questions
23
votes
3 answers

@Html.ActionLink and @Html.DisplayFor at the same time (not right, but it describes what I want to do)

I have the following table located in a view within a controller named Student (/Student/Details/1): @foreach (var item in Model.Enrollments) { @Html.DisplayFor(modelItem => item.Course.Title) …
Ecnalyr
  • 5,792
  • 5
  • 43
  • 89
20
votes
5 answers

How do I create the correct route values for this ActionLink?

The Model of SearchResults.aspx is an instance of PersonSearch; when the request for a new page arrive (a GET request), the action method should take it and compute the new results. [AcceptVerbs(HttpVerbs.Get)] public ActionResult…
gremo
  • 47,186
  • 75
  • 257
  • 421
19
votes
4 answers

Using HTML tags inside linkText of Html.ActionLink

Is it possible to use HTML tags in the linkText of Html.ActionLink? For instance, if I wanted to bold part of the text of a link I would try something similar to this: <%= Html.ActionLink("Some bold text", "Index")%> but that just…
Tim Banks
  • 7,099
  • 5
  • 31
  • 28
19
votes
5 answers

MVC ActionLink add all (optional) parameters from current url

The very famous ActionLink: <%: Html.ActionLink("Back to List", "Index")%> Now, this link is in my Details view. The Index view is a search page. The URL of that looks like this:…
Stefanvds
  • 5,868
  • 5
  • 48
  • 72
15
votes
3 answers

RavenDB Ids and ASP.NET MVC3 Routes

Just building a quick, simple site with MVC 3 RC2 and RavenDB to test some things out. I've been able to make a bunch of projects, but I'm curious as to how Html.ActionLink() handles a raven DB ID. My example: I have a Document called "reasons" (a…
SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
14
votes
2 answers

How to dynamically alter the class of an Html.ActionLink in MVC

I'm looking for a way to alter the class of an ActionLink in the controller based on specific criteria (not found in the model so I can't write a conditional in the view itself). But i can't seem to find the ViewData("name") that allows me to work…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
13
votes
4 answers

MVC Ajax.ActionLink doesn't find POST method

I have a POST method declared in my controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateComments(int id, string comments) { // ... } and an ActionLink in my view: <%= Ajax.ActionLink("update", "UpdateComments", …
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
13
votes
3 answers

How Can I Stop ASP.Net MVC Html.ActionLink From Using Existing Route Values?

The website I'm working on has some fairly complicated routing structures and we're experiencing some difficulties working with the routing engine to build URLs the way we need them to be built. We have a search results page that uses RegEx based…
Zac Seth
  • 2,742
  • 5
  • 37
  • 56
12
votes
5 answers

Is it possible to use an ActionLink containing an element?

As the question says, Is it possible to use an ActionLink containing an element, and if not, what is the best way to achieve it? For example, lets say I have a Span element, I want the whole thing to be a hyperlink... The following works:
Wil
  • 10,234
  • 12
  • 54
  • 81
12
votes
1 answer

Using Html.ActionLink and Url.Action(...) from inside Controller

I want to write an HtmlHelper to render an ActionLink with pre-set values, eg. <%=Html.PageLink("Page 1", "page-slug");%> where PageLink is a function that calls ActionLink with a known Action and Controller, eg. "Index" and "Page". Since…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
12
votes
1 answer

How can I include a bookmark/fragment in an ActionLink?

Possible Duplicate: Including an anchor tag in an asp.net mvc Html.ActionLink The code : @Html.ActionLink("Link", "Action", "Controller", new { id = Id } ) For the moment I can generate links like this : http://mywebsite/Controller/Action/Id I…
Giu
  • 1,832
  • 2
  • 16
  • 31
10
votes
2 answers

Raw ActionLink linkText

I want to put a button as the text of an @ActionLink() but I can't because it HTML-escapes my string... I found the @Html.Raw() mechanism and have tried the @ActionLink().ToHtmlString() but can't figure out how to put it together... I found an…
ekkis
  • 9,804
  • 13
  • 55
  • 105
10
votes
1 answer

Conditionally add htmlAttributes to ASP.NET MVC Html.ActionLink

I'm wondering if it's possible to conditionally add a parameter in a call to a method. For example, I am rendering a bunch of links (six total) for navigation in my Site.Master: <%= Html.ActionLink("About", "About", "Pages") %> | <%=…
macca1
  • 9,541
  • 9
  • 32
  • 41
9
votes
3 answers

Image button in ActionLink MVC

How to put image instead text in ActionLink button: @Html.ActionLink("Edit-link", "Edit", new { id=use.userID }) So how to change text "Edit-link" to image? Thanks for any idea.
Daniel K Rudolf_mag
  • 287
  • 2
  • 5
  • 18
8
votes
1 answer

MVC ActionLink omits action when action equals default route value

I have the following routes defined for my application: routes.MapRoute( "Referral", // Route name "{referralCode}", // URL with parameters new { controller = "Home", action = "Index" } // Parameter defaults ); routes.MapRoute( …
rjygraham
  • 145
  • 1
  • 8
1
2
3
40 41