ASP.NET MVC Controls
Registering Resources

By default, all the resources required to use the available controls get registered, when you create a new application using the ComponentOne MVC template. But, you need to register resources manually in case you create a project using standard Visual Studio templates.

Complete the following steps to register the required resources for using ASP.NET MVC Edition controls:

  1. From the Solution Explorer, open the folders Views | Shared.
  2. Double click _Layout.cshtml to open it.
  3. Add the following code between the <head></head> tags. This step will register all the MVC controls used in your application, except FinancialChart, FlexSheet, MultiRow, FlexViewer and OLAP controls.
    Razor
    Copy Code
    @Html.C1().Styles()
    @Html.C1().Scripts().Basic()
    
    HTML
    Copy Code
    <c1-styles />
    <c1-scripts>
            <c1-basic-scripts />
    </c1-scripts>
    
  4. (Optional) If you want to use any specific control such as FinancialChart, FlexSheet, MultiRow, FlexViewer and OLAP control in your application, replace the above code with the following code in  _Layout.cshtml. You can add or remove the controls depending upon your project requirements.
    Razor
    Copy Code
    @Html.C1().Styles()
    @Html.C1().Scripts().Basic().Finance().FlexSheet().FlexViewer().Olap().MultiRow()
    
    HTML
    Copy Code
    <c1-styles />
    <c1-scripts>
            <c1-basic-scripts/>
            <c1-finance-scripts>
            <c1-flex-sheet-scripts />
            <c1-flex-viewer-scripts />
            <c1-olap-scripts />
            <c1-multi-row-scripts />
    </c1-scripts>
    

ASP.NET MVC Edition supports conditional resource registration. Wherein, you may register only the resources that you wish to use in your application to keep your application lighter. For example, the following code will register the resources required to use FlexChart and FlexPie.

Razor
Copy Code
@Html.C1().Scripts().Basic(b=>b.Grid().Chart())
Razor
Copy Code
<c1-scripts> <c1-basic-scripts bundles="Grid, Chart" /> </c1-scripts>
Note: If your view is not using _Layout.cshtml, then add the above code to register resources towards the top of your view page.

Styles

To use styles in your MVC application, you need to register the styles (CSS) files which includes the resources for a theme and culture. You can also apply different themes using Theme method, the supported themes are defined in C1.Web.Mvc.Themes static class.

_Layout.cshtml
Copy Code
@Html.C1().Styles().Theme("cocoa")
_Layout.cshtml
Copy Code
<c1-styles theme="cocoa" />
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback