Questions tagged [html.actionlink]

html.actionlink is an HTML Helper in ASP.NET MVC framework. It enables to render an HTML link by using HTML.ActionLink().

With MVC, HTML helpers are much like traditional ASP.NET Web Form controls.

Just like web form controls in ASP.NET, HTML helpers are used to modify HTML. But HTML helpers are more lightweight. Unlike Web Form controls, an HTML helper does not have an event model and a view state. MVC includes standard helpers for the most common types of HTML elements, like HTML links and HTML form elements.

285 questions
89
votes
3 answers

ActionLink htmlAttributes with hyphens

This works Edit But this doesn't. Why? @Html.ActionLink("Edit", "edit", "markets", new { id = 1…
Pavel Hlobil
  • 1,762
  • 1
  • 15
  • 22
78
votes
4 answers

How to pass Area in Url.Action?

The problem in Html.ActionLink() is that you can't add additional html content inside the tag that it generates. For example, if you want to add an icon besides the text like: Go to…
doncadavona
  • 7,162
  • 9
  • 41
  • 54
73
votes
21 answers

ASP.NET MVC Ajax.ActionLink with Image

is there anyway to have an image act as an ajax actionlink? I can only get it to work using text. Thanks for your help!
Jonl
72
votes
10 answers

How do I redirect a user when a button is clicked?

I have a view with a button. When the user clicks the button I want them redirected to a data entry view. How do I accomplish this? I should mention the views are created, tested, and functioning. I can get to them by typing the url. I looked for…
DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233
39
votes
4 answers

Using "data-toggle" with Html.ActionLink

I want to use "data-toggle" wiht actionLink. Like this; Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert", data-toggle="modal" }) Unfortunately, doesn't accept. How can i…
nermik
  • 1,485
  • 4
  • 16
  • 24
35
votes
7 answers

on html.actionlink click go to previous page

Currently in a link Customer/businessunit/RepresentativeDetails?RepresentativeId=cd3a7263-78f7-41bd-9eb0-12b30bc1059a I have following code for view @Html.ActionLink("Back to List", "Index") which takes me to this…
Cybercop
  • 8,475
  • 21
  • 75
  • 135
29
votes
6 answers

System.Web.Mvc.HtmlHelper' does not contain a definition for 'ActionLink'

I would like to use custom @Html.ActionLink I am trying to use the following code:- public static class LinkExtensions { public static MvcHtmlString MyActionLink( this HtmlHelper htmlHelper, string linkText, string…
Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68
27
votes
3 answers

Passing parameter to controller action from a Html.ActionLink

Is there anything wrong with this html? I want to have a link in the masterpage to navigate to "CreateParts" view. I have action 'CreateParts' which have a parameter parentPartId in the controller 'PartList'.
  • Suja Shyam
    • 971
    • 2
    • 27
    • 57
  • 21
    votes
    4 answers

    Adding images within Html.ActionLink

    I was trying to create an option to switch between a list view and widget view in ASP.net MVC (with razor view engine). However, I am having some trouble trying to both add an image, as well as scale it to the 'correct height' (the same height as…
    user3913686
    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
    16
    votes
    5 answers

    How to use MVC 3 @Html.ActionLink inside c# code

    I want to call the @Html.ActionLink method inside a c# function to return a string with a link on it. Something like this: string a = "Email is locked, click " + @Html.ActionLink("here to unlock.", "unlock") ;
    15
    votes
    2 answers

    How to use CSS on an Html.ActionLink in C#

    I tried this code <%: Html.ActionLink("Home", "Index", "Home", new { @class = "NavLink" })%> and it links to the css so that I can style the link, but it changes the link to have a different URL that is not to my controller like it is without the…
    pongahead
    • 1,984
    • 3
    • 18
    • 21
    14
    votes
    1 answer

    Asp.Net mvc 5 - How can I pass a complex object as route value in Html.ActionLink() so default model binder can map it?

    I have an object containing searching, sorting and paging parameters as well as an id of a record to be edited. I'd like to pass this object into Html.ActionLink() as a route value object, so that the resulting query string will be correctly mapped…
    user482184
    • 163
    • 1
    • 1
    • 7
    13
    votes
    3 answers

    How to set Dynamic title of @Html.ActionLink from Controller?

    i have @Html.ActionLink("Remove 1034, 1035, 1036", "RemoveSelected") Now i want to set each id from Controller for example: @Html.ActionLink(ViewBag.RemoveSelectedTitle, "RemoveSelected") //this is not work // GET: /TabMaster/ public…
    imdadhusen
    • 2,493
    • 7
    • 40
    • 75
    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
    1
    2 3
    18 19