Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, May 3, 2013 12:39 AM
How do I give an ID to an Html.Action link? Below is my @Html.ActionLink, yet I don't know how to assign it an id.
@Html.ActionLink("informationPage", "Index", "Home", new { @class = "linkStyle" })
All replies (3)
Friday, May 3, 2013 12:50 AM ✅Answered
You can pass in your id like this:
@Html.ActionLink("informationPage", "Index", "Home", new { @class = "linkStyle", id="{put your id here}" })
Friday, May 3, 2013 1:43 AM ✅Answered
I assume that Index is the view under Home Folder.. u can pass id like below...
@Html.ActionLink("informationPage", "Index", "Home", new { @class = "linkStyle", id=Id})
Here Id is nothing but the value which you want to pass..
In controller your Action Result should have input parameter like below...
public ActionResult Index(int id)
{
// Your logic
return View();
}
Thanks,
Atthota.
Friday, May 3, 2013 12:57 AM
Make sure you are passing the correct values for right parameter, you are using route values parameter for html attributes
@Html.ActionLink("informationPage", "Index", "Home", null, new { @class = "linkStyle", id="[someid]" })