ASP. MVC5 Quote ExtJS6 "All-network debut"

Source: Internet
Author: User

Summary: How VisualStuio2015 ASP. NET MVC refers to ExtJS6, using Bundleconfig.

First download ExtJS6.0 GPL version. ExtJS has its own program framework, but we need ASP. NET Mvc5,extjs as the interface library only.

The next step is to extract the core parts of the downloaded ExtJS6, which is the directory structure:

The object to be referenced is all in the build directory, which has more than 400 m and is too large for the VS project reference. First copy the build directory to the VS project directory and rename it to ExtJS60.

1, the directory examples, welcome, file index.html, release-notes.html deleted.

2, delete the debugging files. There are many *debug.js, *debug.scss files in this directory, delete them. With everything

There are more than 40 m left in this process. I can directly use the Http://pan.baidu.com/s/1qYMtE0W password I handled: 1q14.

The next step is to use @scripts.render and @styles.render to refer to ExtJS. MVC provides BundleConfig.cs files for adding JS scripts and CSS styles, view view Unified invocation, and the ability to compress JS and CSS.

\app_start\bundleconfig.cs

usingsystem.web;usingSystem.Web.Optimization;namespacewebapplication1{ Public classBundleconfig {//For more information about bindings, go tohttp://go.microsoft.com/fwlink/?LinkId=301862     Public Static voidregisterbundles (bundlecollection bundles) {bundles. ADD (NewScriptbundle ("~/bundles/jquery"). Include ("~/scripts/jquery-{version}.js")); Bundles. ADD (NewScriptbundle ("~/bundles/jqueryval"). Include ("~/scripts/jquery.validate*")); //use the development version of the MODERNIZR to be used for development and learning. And then, when you're done//when preparing your production, usehttp://modernizr.comto select only the tests that you want on the build tool. Bundles. ADD (NewScriptbundle ("~/bundles/modernizr"). Include ("~/scripts/modernizr-*")); Bundles. ADD (NewScriptbundle ("~/bundles/bootstrap"). Include ("~/scripts/bootstrap.js",                "~/scripts/respond.js")); Bundles. ADD (NewStylebundle ("~/content/css"). Include ("~/content/bootstrap.css",                "~/content/site.css")); //******** own javascript************************.Scriptbundle EXT_SCRIPTBL =NewScriptbundle ("~/extjs"); Ext_scriptbl.include ("~/extjs60/ext-all.js"); Ext_scriptbl.include ("~/extjs60/classic/locale/locale-zh_cn.js");//Chinese ResourcesScriptbundle jquery_scriptbl=NewScriptbundle ("~/jquery"); Jquery_scriptbl.include ("~/scripts/jquery-2.1.4.min.js");      Ext_ScriptBL.Transforms.Clear (); Bundles.      ADD (JQUERY_SCRIPTBL); Bundles.      ADD (EXT_SCRIPTBL); Cssrewriteurltransformwrapper Crut=NewCssrewriteurltransformwrapper (); Stylebundle Stylebl=NewStylebundle ("~/extjs_css_triton"); Stylebl.include ("~/extjs60/classic/theme-triton/resources/theme-triton-all_1.css", Crut); Stylebl.include ("~/extjs60/classic/theme-triton/resources/theme-triton-all_2.css", Crut); Stylebundle StyleBL2=NewStylebundle ("~/extjs_css_neptune"); Stylebl2.include ("~/extjs60/classic/theme-neptune/resources/theme-neptune-all_1.css", Crut); Stylebl2.include ("~/extjs60/classic/theme-neptune/resources/theme-neptune-all_2.css", Crut); Stylebundle StyleBL3=NewStylebundle ("~/extjs_css_gray"); Stylebl3.include ("~/extjs60/classic/theme-gray/resources/theme-gray-all.css", Crut); Bundles.      ADD (STYLEBL); Bundles.      ADD (StyleBL2); Bundles.      ADD (StyleBL3); //******** own JavaScript end************************    }  }   Public classCssrewriteurltransformwrapper:iitemtransform { Public stringProcess (stringIncludedvirtualpath,stringinput) {      return NewCssrewriteurltransform (). Process ("~"+Virtualpathutility.toabsolute (Includedvirtualpath), input); }  }}

Controllers directory right → add → controller →mvc5 controller empty. Controller name Exttest. Add views (do not layout pages)

\views\exttest\index.cshtml

@{Layout = null;}<!DOCTYPE HTML><HTML><Head>    <Metaname= "Viewport"content= "Width=device-width" />    <title>Index</title>@Styles. Render ("~/extjs_css_neptune") @Scripts. Render ("~/extjs")<Scripttype= "Text/javascript">Ext.onready (function() {ext.create ('Ext.tab.Panel', {width: the, Height: -, RenderTo:document.body, items: [{title:'Page 1',}, {title:'Page 2',        }]      }); Ext.Msg.alert (" Ready", "ExtJS Ready");  }); </Script></Head><Body>    <Div>     </Div></Body></HTML>

Run to see the effect:

ASP. MVC5 Quote ExtJS6 "All-network debut"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.