Create an ASP.NET Web Forms Dashboard Application
- 3 minutes to read
This tutorial shows how to create the dashboard web application using the ASPxDashboard control.
Note
Download the completed project: Creating an ASP.NET Web Forms Dashboard Designer Application
Watch the video: Dashboards: Creating a Web Designer & Viewer
- Steps 1-3. Add the Web Dashboard Control
- Steps 4-5. Create a Dashboard Storage
- Steps 6-8. Provide Data
- Step 9. Add Required Client Libraries
- Steps 10-11. Create a Dashboard
- Steps 12-14. Switch to the Viewer Mode
Steps 1-3. Add the Web Dashboard Control
- Run Visual Studio 2012, 2013, 2015 or 2017 and create an ASP.NET Web Application. Next, select the Empty template and click OK.
Add a new Web Form to the application. To do this, right-click the project in the Solution Explorer and select Add | Web Form.
Leave the default ‘WebForm1’ item name and click OK in the invoked dialog.
Drag the ASPxDashboard control from the DX.18.2: Data & Analytics Toolbox tab and drop it onto the page.
Switch the web page to the Design view.
Steps 4-5. Create a Dashboard Storage
- Right-click the project in the Solution Explorer and select Add | Add ASP.NET Folder | App_Data from the context menu. Then, add the Dashboards folder inside App_Data.
Click the control’s smart tag and set Dashboard Storage Folder to the following relative path: ~/App_Data/Dashboards.
This folder contains the saved dashboards’ XML definitions.
Steps 6-8. Provide Data
Right-click the App_Data folder, select Add | Existing Item and locate the nwind.mdb database using the following path:
C:\Users\Public\Documents\DevExpress Demos 18.2\Components\Data\nwind.mdb
Specify a connection string to the added database within the project’s Web.config file as shown below.
<connectionStrings> <add name="nwindConnection" connectionString="XpoProvider=MSAccess; Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\nwind.mdb;" /> </connectionStrings>
Note
Note that the connection string should contain the XpoProvider parameter that depends on the used database type. For details on how to specify connection strings for different database types, see Register Default Data Connections.
In the Page_Load method of WebForm1.aspx.cs, pass the ConfigFileConnectionStringsProvider instance as the SetConnectionStringsProvider method’s parameter to to allow creating new data sources based on connection strings from the Web.config file:
Step 9. Add Required Client Libraries
In the web application’s Web.Config file, go to the DevExpress section and add the “resources” section as shown below.
<devExpress> <!-- ... --> <resources> <add type="ThirdParty" /> <add type="DevExtreme" /> </resources> </devExpress>
This adds the required client libraries to the project, such as jquery, jquery-ui, knockout and globalize.
Note
The basic cldr content needed for the Web Dashboard is included in the library. However, for locales other than “en” (or currencies other than “USD”), cldr content should be loaded additionally (read more in the Globalize documentation).
Steps 10-11. Create a Dashboard
The designer application is now ready. Build and run the project.
Your application should look as follows:
For instructions on how to create your first dashboard in the Web Designer, go to Create a Dashboard using the Web Dashboard.
Steps 12-14. Switch to the Viewer Mode
After you create and save a dashboard, you can now switch your Dashboard Designer application to the Viewer mode.
- In the project, switch to WebForm1.aspx and click the control’s smart tag.
Set the Working Mode option to the ‘ViewerOnly’.
- Run the application. The ASPxDashboard control displays the dashboard from ~/App_Data/Dashboards.