Declare scripts in partial views in ASP.NET MVC

0

I'm working with ASP.NET MVC, JQuery, Javascript

I understand that when you work with a main view that calls a partial view, the partial view is injected into the main view. If that were true, it would no longer be necessary to declare the validation scripts in the partial view, such as:

<script src="~/scripts/jquery-3.1.1.min.js"></script>
<script src="~/scripts/jquery.validate.min.js"></script>
<script src="~/scripts/jquery.validate.unobtrusive.min.js"></script>

In other words or in other words, is it necessary to declare the same scripts in the partial view, having previously declared in the main view?

    
asked by Pedro Ávila 25.02.2017 в 22:13
source

1 answer

1

Indeed, when using partial views, either with Html.Partial() or with Html.Action() , it is not necessary to declare the scripts that are used in the page that invokes them, only those that do not.

Of course, in general it is better not to have scripts in the partial views for simplicity.

    
answered by 26.02.2017 в 22:56