Friday, September 20, 2019

Difference between Html.RenderBody() and Html.RenderSection() in ASP.NET MVC

The following table lists the differences between the RenderBody() and RenderSection() methods.
RenderBody()RenderSection()
The RenderBody() method must be present in the layout view.The RenderSection() method is optional.
RenderBody() renders all the content of the child view which is not wrapped in the named section.RenderSection() renders only a part of the child view which is wrapped under the named section.
Multiple RenderBody() methods are NOT allowed in a single layout view.Multiple RenderSection() methods are allowed in a single layout view.
The RenderBody() method does not include any parameter.The RenderSection() method includes boolean parameter "required", which makes the section optional or mandatory. If the required parameter is true, then the child view must contain the section.

No comments:

Post a Comment

Get max value for identity column without a table scan

  You can use   IDENT_CURRENT   to look up the last identity value to be inserted, e.g. IDENT_CURRENT( 'MyTable' ) However, be caut...