Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know if a non-required RenderSection exists?

@* Omitted code.. *@ @RenderBody() @RenderSection("Sidebar", required: false) 

Is there any way to know in the Omitted code part if the RenderSection Sidebar exists or not?

like image 848
Thomas Bonini Avatar asked Jul 20 '11 22:07

Thomas Bonini


1 Answers

@if (IsSectionDefined("Sidebar")) {     @RenderSection("Sidebar") } else {     <div>Some default content</div> } 
like image 163
Darin Dimitrov Avatar answered Sep 28 '22 21:09

Darin Dimitrov