I'd like to get the name of my partial view in my layout page to determine which div is going to be active. Because of the design I cannot css this nicely so I went for a more sloppy approach.
In my _Layout.chtml The Renderbody loads my content. And here depending on which button I press, I get a map or a list. These are both functions in my controller and what I would like to do is get the functionname or partial view so I can then decide which I want to show.
so I wanted to do something like this in my _Layout.chtml
@if ( get the controllername or view == mapname or listname)
{
<div>
@Html.Partial("tabMap")
</div>
}
else
{
<div>
@Html.Partial("tabList")
</div>
}
Any quick fix to do this ?
access the RouteData
dictionary from the ViewContext
Object
will be like this
@ViewContext.RouteData.Values["Controller"]
with the RouteData
Dictionary you can get all the info needed about the controller , action and extra parameters names , depending on them output the data you want
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.