Limit JavaScript and CSS files on ASP.NET MVC 2 Master Page based on Model and View content
问题 I want to include certain .js and .css files only on pages that need them . For example, my EditorTemplate DateTime.ascx needs files anytimec.js and anytimec.css . That template is applied whenever I use either the EditorFor or EditorForModel helper methods in a view for a model with a DateTime type value. My technique: I've put this condition into the <head> section of my master page. It checks for a DateTime type property in the ModelMetadata. <% if (this.ViewData.ModelMetadata.Properties