Posts Tagged ‘’

Using the Charting Control in ASP.NET Webform

February 27, 2012 Leave a comment

The following steps will give you a brief intro on how to use the chart control, from there you can easily extend and provide additional functionalities

The chart control has separate definition sections for data and chart type, with this, it is possible to create multiple chart types using the same data points.

  1. First create a blank webform
  2. Then using the design view, click on toolbox and search for the chart control under the data section
  3. You will now see the placeholder for the chart appear in your webform
  4. This is the default column chart, you can change the type simply by clicking on the chart and then the arrow that appears
  5. You can link the data source via standard data adapters like SQL, EF, XML etc. But this example will add the data via code.

    Inside the page_load event of the page, add the following code

    //Create 6 data points with x values from 1 to 5
    for (var x = 1; x < 6; x++)
       //set it such that the y value mirrors the x value 
       var y = x; 
       //add the following point to the chart 
       Chart1.Series[0].Points.AddXY(x, y); 

  6. Press F5 to run the website and view your chart
Categories: ASP.NET Tags: ,

HttpHandlers and Session State

July 6, 2011 Leave a comment

Note to myself:

Httphandlers by default cannot access session state. In order for them to access session state, you need to

1. add using System.Web.SessionState;
2. public class xHandler : IHttpHandler, IRequiresSessionState { or
public class xHandler : IHttpHandler, IReadOnlySessionState {

Categories: Uncategorized Tags: