Describing my problem with a school example;
Say there is a Main Menu in _Layout.chtml
with links of few classes, i.e. Class 1, Class 2, Class 3
,... Each link shows a list of students in a Grid
and each Row
has some Edit
link. That link lands us on Edit
screen for Student
records.
Now Student properties to be edited are categorized in multiple sections i.e. Personal, Educational, Sports, Transport
. So there need to a Menu
to be displayed on left column for each category of Student
properties. Each category has its own Controller
, Service
& Repository
. So the Link
s in the Menu
need to send Student ID
to the respective Controller
, So it can fetch & create the specific properties Model
of particular Student
and send to View
.
I wanted to be guided for how to put that Menu
. Though I guess I am correct when written it in Partial View
& included in each View
of property set.
Problem is that the Link
doesn't work when Controller
name is added as below:
@Html.ActionLink("Sports Properties", "EditSportsProps", "SportsProperties", new {ID = Model.ID})
But works when Controller
name is not added as below:
@Html.ActionLink("Sports Properties", "EditSportsProps", new {ID = Model.ID})
Hence I am narrowed to put all functionality in same controller.
Controller
s from a Partial View
? Student ID
is required throughout, Is there a way to fetch it from route URL "ControllerName/ActionName/Id
" in Controller
? as ID
is there in it.There is no overload for ActionLink(HtmlHelper, String, String, String, Object)
You can use overload, LinkExtensions.ActionLink Method (HtmlHelper, String, String, String, Object, Object)
Thus change your code as, pass null
for HTML attributes
@Html.ActionLink("Sports Properties",
"EditSportsProps",
"SportsProperties",
new {ID = Model.ID}, null)
For more info visit LinkExtensions.ActionLink
Note: When you are not putting controller name then it works because you are using ActionLink(HtmlHelper, String, String, Object)
overload