top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Explain Sections is ASP.Net MVC?

0 votes
149 views
Explain Sections is ASP.Net MVC?
posted Aug 24, 2016 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Section are the part of HTML which is to be rendered in layout page. In Layout page we will use the below syntax for rendering the HTML :

@RenderSection("TestSection") 

And in child pages we are defining these sections as shown below :

@section TestSection{
<h1>Test Content<h1>
} 

If any child page does not have this section defined then error will be thrown so to avoid that we can render the HTML like this :

@RenderSection("TestSection", required: false)
answer Aug 26, 2016 by Shivaranjini
...