ASP.NET Core MVC Controls | ComponentOne
Configuring your MVC Application / Registering Resources
In This Topic
    Registering Resources
    In This Topic

    When you create a new application using the ComponentOne MVC template, the resources required to use the C1 MVC controls get registered automatically. But, you need to register resources manually in case you want to use any ASP.NET MVC Edition control in an existing application or 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, OLAP, TransposedGrid, and TransposedMultiRow controls.
      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, OLAP, TransposedGrid, and TransposedMultiRow 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.
      HTML
      Copy Code
      <c1-scripts>
         <c1-basic-scripts/>
         <c1-finance-scripts>
         <c1-flex-sheet-scripts />
         <c1-flex-viewer-scripts />
         <c1-olap-scripts />
         <c1-multi-row-scripts />
         <c1-transposed-grid-scripts />
         <c1-transposed-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. The list of controls which support conditional resource registration is as follows:

    For example, the following code registers the conditional resources required to use FlexGrid and FlexChart.

    Razor
    Copy Code
    <c1-scripts>
    <c1-basic-scripts bundles="Grid, Chart" />
    </c1-scripts>
    

    Similarly, you can also register the conditional resources required to use CollectionView, Input and Gauge.

    Note: If your view is not using _Layout.cshtml, then add the above code to register resources towards the top of your view page.