Friday, September 20, 2019

What is @section scripts and what it is used for

section allows you to add something in a view which will be added in the layout. ie:-
view
@section scripts {

    <script>

      alert('foo');

    </script>

}
layout
@RenderSection("scripts", false)
now this named section scripts will be rendered where you have specified in the layout.
@RenderSection also has 2 signatures:-
public HelperResult RenderSection(string name) // section required in the view
public HelperResult RenderSection(string name, bool required)

No comments:

Post a Comment

No String Argument Constructor/Factory Method to Deserialize From String Value

  In this short article, we will cover in-depth the   JsonMappingException: no String-argument constructor/factory method to deserialize fro...