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
0
votes
1 answer

Hard Code MVC Route Value

I'm trying to utilize the HTML.ActionLinks in MVC. I have a route definition like so: routes.MapRoute( name: "RestaurantCommon", url: "Rest/{siteName}/Admin/{action}/{id}", defaults: new { controller = "AdminCommon", action =…
Jon Harding
  • 4,928
  • 13
  • 51
  • 96
0
votes
1 answer

How to pass a list of Guids through an ActionLink parameter?

Basically I have a list of Guids and I want to pass this list as a parameter to a controller action. This is what I come up with so far, but its not working. var contactsParam = new Dictionary(); var count = 0; foreach (var…
Ben
  • 187
  • 3
  • 12
0
votes
1 answer

How to insert an image in ActionLink (View model)

I want to display an image for each bike, but these codes didn't work:
    @foreach (var bike in Model.Bikes) {
  • @Html.ActionLink(bike.Name, "Categories", new { id = bike.Id, name = bike.Name, @class = "image"}, null)
  • }…
Trung Pham
  • 233
  • 2
  • 6
  • 19
0
votes
1 answer

How do I add a route without affecting Html.ActionLink

My routes : public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //Add a custom Route that implements IRouteHandler Route metadata = new Route("metadata", new…
0
votes
1 answer

Order List in MVC 4 ASP.NET i.e. Controller receiving 2 variables

I am trying to rewrite the default MVC Index controller that displays the list of records from a database. I am trying to have an order by function on 1 of the headings AND the ability to search on the page: Controller code: public ActionResult…
Gman16
  • 183
  • 2
  • 6
  • 15
0
votes
1 answer

@Html tags are not displayed in a div?

I'm working on asp.Net MVC4 project, and I need to create ActionLink for each element of a list. Here is what I have done:
@foreach(Elections.Domain.Models.Kalam kalam in Model.Kalams) { …
Hanady
  • 779
  • 2
  • 15
  • 38
0
votes
0 answers

parameters and class name in @Html.ActionLink

How can I include parameters and class name in @Html.ActionLink @Html.ActionLink(item.Name, item.ActionName, item.ControllerName, new RouteValueDictionary(item.Parameters), new Dictionary{{"class",item.ClassName}})) Error I get…
user2893547
  • 135
  • 1
  • 9
0
votes
3 answers

Creating Html.ActionLink in C# string

I'm looking for a way to generate Html.ActionLinks through C#. How would I go and do this, I've tried this: public static string CreateSubjectTree(SqlConnection con) { StringBuilder result = new StringBuilder(); …
Michael Tot Korsgaard
  • 3,892
  • 11
  • 53
  • 89
0
votes
3 answers

HTML.ActionLink returns null

I have my View page where i have this code: <%: Html.ActionLink("Edit", "Edit", "Admin", new { id = item.Username })%> And here is my controller public ActionResult Edit(String id) { String x = id; } But String x have value…
daidai
  • 531
  • 5
  • 10
  • 22
0
votes
2 answers

Displaying Multiple Image Links instead of Text in WebGrid?

I have a WebGrid definition and three links in a single column by using Html.ActionLink. But, when I do not use "LinkText" property, the applicantId property is passed as null value to the Controller. On the other hand, when just using LinkTexts…
Jack
  • 1
  • 21
  • 118
  • 236
0
votes
1 answer

Show link to absolute url if result is equal to string in MVC3 ASP

I have the following code which returns one of the 3 options ("Please check availability","Low Stock" or "Available") in a controller. How can I change the view (2nd part in order to display a link "here" that will open a new window to an external…
0
votes
2 answers

Html.Action passing value from model returns null

I'm trying to pass a value into an Html.Action using FirstOrDefault to return the first entry in an array of values. The value is not picked up and I keep getting a null exception. The family variable picks up the correct values from the model as a…
melkisadek
  • 1,043
  • 1
  • 14
  • 33
0
votes
1 answer

Html.ActionLink Action Straggler

I have a nav menu with links structured like so:
  • @Html.ActionLink("Perkins Engines",…
Andrew Walters
  • 4,763
  • 6
  • 35
  • 49
0
votes
1 answer

Html.ActionLink adding params with ? and & instead of slashes

Here's my simple actionlink: @Html.ActionLink(trip.TripDescription, "Index", "Home", new { trip = trip.Trpp, year = trip.TripYear }) Here is my route for that link: routes.MapRoute( "Index", …
0
votes
3 answers

MVC actionlink parameter never sending

Can anyone tell me why my parameters in the following code are always null when the controller action is called: <% foreach (var row in Model) { %> <%=Html.ActionLink("Edit", "Edit", "Customer", new { controller = "Customer",…
collusionbdbh
  • 701
  • 1
  • 6
  • 18