[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Collapse]Chart Control
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Design-Time Features
   [Expand]Visual Elements
     How to: Add a Chart to a Web Application
     How to: Add a Chart to a Web Page (Runtime Sample)
     How to: Add a Chart to an ASPxCallbackPanel during its Callback (Runtime Sample)
     How to: Bind an Individual Series to a Data Source (Runtime Sample)
     How to: Bind a Web Chart to Data (Runtime Sample)
     How to: Bind a Web Chart to an ASPxPivotGrid
     How to: Show Custom Data Over a Web Chart Using ASPxPopupControl
     How to: Use the Client-Side Model of the WebChartControl
     How to: Show Custom Tooltips for a WebChartControl
     How to: Invoke the Client Chart Designer
     How to: Configure a Chart for Printing
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Add a Chart to a Web Page (Runtime Sample)

This tutorial demonstrates how a chart can be generated and shown in a web page with a button click. For an alternative approach to this task, refer to How to: Add a Chart to an ASPxCallbackPanel during its Callback (Runtime Sample).

To demonstrate how this can be done, do the following.

  1. Create a new ASP.NET Web Application (Visual Studio 2010, 2012, 2013, 2015 or 2017), or open an existing one.

  2. Switch to the Design view of the Default.aspx page, and from the DX.18.1: Common Controls toolbox tab, drop an ASPxButton onto the page. We'll handle its Click event, to generate a web chart.

  3. Add the required assemblies to the project.

    Note that if you prefer that the assemblies be added automatically (by dropping a WebChartControl instance onto the page), this affects your web application's Web.config file. To learn about the changes being made to it, refer to Adding a Web Chart.

  4. Now, double-click the ASPxButton1, to handle its Click event. Add the following code to the event handler.

    Note that prior to accessing elements and properties of a dynamically created WebChartControl, it should be added to the Page.Form.Controls collection.

Run the web application, and click the ASPxButton1 to see the resulting chart.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1171.

Expanded See Also

Is this topic helpful?​​​​​​​