Custom Files

Custom Files enables you to add your own files to the project. Basically, a custom file is a blank page with the layout of the project for you to add your own content so it will have a consistent look and feel like other generated files.

 

How to Use

To create a Custom File, simply right click the database pane or click Edit in the main menu, then select Add File, the following form will show:

The properties are as follows:

File Name (wihtout extension)

File name WITHOUT extension. The generated script will be named as <FileName>.cshtml.

Notes

  1. Use alphanumerical characters only,
  2. Do not include file extension,
  3. Do not include path,
  4. If you have selected Lowercase in Generate tab (see Generate Settings), the file name will be converted to lowercase during generation.
  5. The file name cannot be same as any table (including view, Custom View and report) name.
  6. The file name cannot be same as any pages of table (including view, Custom View and report), e.g. do not enter a file name like "<table>list" where <table> is a table name.
Caption The caption of the page. This is similar to table caption for a table and will be shown up in the menu and in the Breadcrumbs of the page.
Use layout Specify whether to use _Layout.cshtml in the file so it will be consistent with other generated scripts.

After entering above properties, click OK button to save. The Custom File will show up in the database pane under the Custom Files node:

 

To edit the Custom File properties, right click the Custom File in the database pane and select Edit File.

To delete a Custom File, right click the Custom File in the database pane and select Delete File.

To enter content for the file, select the Custom File in the database pane , then select the Code tab (which contains Server Events, Client Scripts and Custom Templates) in the right pane.

Scroll down the treeview or collapse the Server Events and Client Scripts node, select the Custom Templates -> Table-Specific -> Custom File -> Content node, then you can enter or paste your content in the editor:



Then just save your project generate and run your scripts in your browser as usual.

 

Important Although it is convenient to save your own files in the project, you should avoid saving all the contents in the project or the project will become so large that the performance of the UI will be affected. If the file content is large, you can put the content in an external file and then include it in the Custom File. If the number of files is large, put the minimum number of files in the project by Custom Files only, you can generate a blank Custom File and duplicate it as containers for other files, then just add menu items to the project by the Menu Editor for those external files.

 

Examples

Example 1 - Insert an external file instead of saving the page content in the project.

@await Html.PartialAsync("MyPage")

 

Example 2 - Add a Bootstrap Panel in the page to show some news.

<div class="panel panel-default">
    <div class="panel-heading">Latest news</div>
    <div class="panel-body">
        <p>ASP.NET Maker 2017 is released</p>
    </div>
</div>

The result:


Example 3 - Add multiple Bootstrap Panels in the page as a dashboard page. Use database helper to execute SQLs and display data as HTML table.

@{
    var dbhelper = ew_GetConn("DB"); // Create instance of connection by the database id (database variable name)
}
<div class="panel panel-default">
    <div class="panel-heading">Out of stock products</div>

@{
var sql = "SELECT DISTINCT " +
    "categories.CategoryName AS CategoryName," +
    "products.ProductName AS ProductName," +
    "products.QuantityPerUnit AS QuantityPerUnit" +
    " FROM categories INNER JOIN products ON (categories.CategoryID = products.CategoryID)" +
    " WHERE " +
    "products.UnitsInStock <= 0";
var options = new Dictionary<string, object>();
options.Add("fieldcaption", true);
options.Add("tablename", new List<string>() {"products", "categories"});
}
@Html.Raw(dbhelper.ExecuteHtml(sql, options)) @* Execute a SQL and show as HTML table *@
</div>
<div class="panel panel-default">
<div class="panel-heading">Discontinued products</div>
@{
sql = "SELECT DISTINCT " +
    "categories.CategoryName AS CategoryName," +
    "products.ProductName AS ProductName," +
    "products.QuantityPerUnit AS QuantityPerUnit," +
    "products.UnitsInStock AS UnitsInStock" +
    " FROM categories INNER JOIN products ON (categories.CategoryID = products.CategoryID)" +
    " WHERE " +
    "products.Discontinued = True";
}
@Html.Raw(dbhelper.ExecuteHtml(sql, options)) @* Execute a SQL and show as HTML table *@
</div>

The result:

Note Other than ExecuteHtml(), there are other useful methods in the connection class, refer to the source code of the cConnectionBase class in the template for details.

 ©2004-2017 e.World Technology Ltd. All rights reserved.