In the design page if you want to add libraries for script files and CSS files so for doing that in MVC architecture you need to use two tags :
1 Styles.Render
2 Scripts.Render
Style.Render is used to add bundle of CSS files. Styles.Render create style tag for the CSS.
Scripts.Render is also used to add all Script files by searching script tag for the Script .
Here is the example:
/* This is the repository for all the script files */
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
/* This will include the reference of all the library files into your application */
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
So we have the class which contain all the collection of the script files to include these references into your project
@*@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}*@
You need to add it into your view if you want to apply it on single view.
If you want to make it global for all view add it in the Layout.cshtml which is in View shared folder.
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
0 Comment(s)