ASP.Net: Do I need to add javascript source of _ValidationScriptsPartial.cshtml to _layout.cshtml?
Partial Views are meant to be used inside other views. You would not normally add the validation scripts to the _layout.cshtml
since that (_layout.cshtm
) is used on every page.
However, if you have a view where you need to use these scripts you just add the partial view inside the .cshtml
file of your view like this:
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
If you created a standard web project with identity using VS 2015 then you can see an example of this usage in Views/Account/Register.cshtml