Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:23:53+00:00 2026-06-02T14:23:53+00:00

I have two @Html.ActionLink’s one works and one does not and I cannot figure

  • 0

I have two @Html.ActionLink’s one works and one does not and I cannot figure out why?

They are both within the same controller: StoreController and both call ActionResults within different controllers, this is the one that works and calls the Index function within the Director Class:

<ul>
@foreach (var item in Model)
{
    <li>
    <h2>@item.Title</h2>
    </li>
    <li class = "lihead">
    Directed by 
    @Html.ActionLink((string)item.Director.Name, "Index", "Director", new { searchString = item.Director.Name }, null)
    </li>
    <li>
    <i>@item.Synopsis</i>
    </li> 
    <li class = "lihead">
    Price per ticket £
    @item.Price
    </li>        
}

This is the one that does not work:

 @foreach (var item in Model) {
        @Html.ActionLink("Check Availability", "CheckAvail", "Booking", new { id = item.ShowId })

}

This one calls within the StoreController when I want it to call the CheckAvail function within the BookingController. However it does work when I amend it as so:

 @foreach (var item in Model) {
        @Html.ActionLink("Check Availability", "CheckAvail", "Booking")}

But I need it to take through the ShowId to the function???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:23:59+00:00Added an answer on June 2, 2026 at 2:23 pm

    Use it like this

    @Html.ActionLink("Check Availability", "CheckAvail", "Booking", new { @id = item.ShowId },null)
    

    It is using this overload

    public static MvcHtmlString ActionLink(
        this HtmlHelper htmlHelper,
        string linkText,
        string actionName,
        string controllerName,
        Object routeValues,
        Object htmlAttributes
    )
    

    http://msdn.microsoft.com/en-us/library/dd504972.aspx

    the last parameter is the HTML attribute. If you have some HTML atribute to pass, you pass it there instead of null

    @Html.ActionLink("Check Availability", "CheckAvail", "Booking", new { @id = item.ShowId },new { @class="myCssClass"} )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two templates for my HTML email: one for bigger screens, and one
I have two images in the background of my html doc. One positioned top
i have two html.actionlinks: <%= Html.ActionLink(Activate, ActivateJob, Management, new { selectedObject = Model.ID },
I have two actionlinks on my MVC view like this: <%= Html.ActionLink (click me,Partial1,Temp,new
I am having problems with Html.ActionLink when I have a route that takes one
I have two HTML buttons; one submits a form and one closes the container
I have two html files, one contains the other with an iframe, and I
OK, I have two HTML select elements and a button. I need to disable
I have those two html radio buttons and textarea. I basically want to enable
lets say i have two pages links.html & contents.php ... first page contains only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.