Can anyone please let me know if this functionality is even doable, i have a Partial View that is rendered on the Layout view that is inherited by all the views.
Now I have one view that I want to have the look and feel inherited from the Layout view but not have the Partial view that comes with the LayOut..
Is there a way I can access the Div defined in the _Layout view on my view that inherits the layout and hide that div on my view?
I tried writing a script but it is not working... ?
(the second link is a tutorial that contains decriptions on how to design the layout to include partial views using the Html.RenderAction() method. Also, you may look at the Html.RenderSection() method.
Also, there is an interesting post about Layouts with Razor: ASP.NET MVC 3: Layouts with Razor that you may find useful.
rishi23
Member
33 Points
76 Posts
MVC Partial view
Jan 09, 2013 06:55 PM|LINK
Hi
Can anyone please let me know if this functionality is even doable, i have a Partial View that is rendered on the Layout view that is inherited by all the views.
Now I have one view that I want to have the look and feel inherited from the Layout view but not have the Partial view that comes with the LayOut..
Is there a way I can access the Div defined in the _Layout view on my view that inherits the layout and hide that div on my view?
I tried writing a script but it is not working... ?
bruce (sqlwo...
All-Star
36644 Points
5432 Posts
Re: MVC Partial view
Jan 09, 2013 07:45 PM|LINK
why do it client side? in the layout
@if (IsSectionDefined('optional')) { @RenderSection('optional')}
else { @Html.Partial('optional') }
then to override the partial optional in the view its:
@section optional {}
april_123456
Participant
775 Points
246 Posts
Re: MVC Partial view
Jan 10, 2013 12:54 AM|LINK
Hello Rishi,
With regards to your question, please view the following which has similiar situation:
http://stackoverflow.com/questions/6018362/how-to-layout-a-page-with-mvc3-razor
http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-10
(the second link is a tutorial that contains decriptions on how to design the layout to include partial views using the Html.RenderAction() method. Also, you may look at the Html.RenderSection() method.
Also, there is an interesting post about Layouts with Razor: ASP.NET MVC 3: Layouts with Razor that you may find useful.
Best of Luck,
With Kind Regards,
rishi23
Member
33 Points
76 Posts
Re: MVC Partial view
Jan 10, 2013 02:10 AM|LINK
The solution suggested seems to be working perfectly fine. Thank you very much I think i have to update my knowledge on Razor/MVC way too much.