I using Jquery tabs plugin to have tabs in my view.
I want <li><a href="../JobDetails/Index/1234">JobDetails</a></li> as my first tab.
For this I am doing
<li>@Html.ActionLink("JobDetails",
"Index", // <-- ActionMethod
"JobDetails", // <-- Controller Name.
new { id = 1234 }
)</li>
But I view source show me this link
<li><a href="/Coordination?Length=10" id="1234">JobDetails</a></li>
where Coordination is my controller name and I am having these tabs on Coordination controller and Action name(ViewName) is Index.
I am not sure why I am geting Controller name as Coordination even i name it as JobDetails.
That's because you are using the wrong overloaded method. Try this instead:
<li>
@Html.ActionLink
(
"JobDetails",
"Index", // <-- ActionMethod
"JobDetails", // <-- Controller Name.
new { id = 1234 },
null // pass a null value for the htmlAttributes object
)
</li>
Your original overloaded method is this:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
Object routeValues,
Object htmlAttributes
)
As you can see from the above parameter names, you are passing in "JobDetails" as your link text, so on and so forth. That's why you're getting the rendered markup.
But by using this overload, you just need to pass null for the htmlAttributes object to get your desired markup:
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
Object routeValues,
Object htmlAttributes
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With