I would like to have one view called Example and have the ability to update and load different partial views into one html div tag. In the case below I would like the page to display a details partial if the URL parameter is an id or a grid of results if the URL parameter is search.
Optional URL parameters:
…./Example?id=1234
…./Example?search=ccc
User would pass in one of the above and either _details.cshtml or _grid.cshtml would update the details div below.
Div tag in Example.cshtml
<div id="Details"></div>
I’m just stuck on where this partial view filtering would take place, jquery or in the controller?
Any help would be appreciated.
Your controller should pass a view model to the view. This view model could the partial to be loaded:
and then based on the presence of the id or search parameters the controller will populate this property:
and in the corresponding view: