Like me, everybody who reads msdn documentation thinks that only way to generate charts in Visual Studio is by adding asp:chart control in the aspx page and make necessary changes to web.config file, but what if this is not possible or for various reasons you are not allowed to change the configuration file and has to work with the code and display charts in aspx page. How would you do it?, well there are several ways to achieve this.
- Using web services/WCF generate chart and send back to UI to display it.
- Using Jquery and generic handler.
- Create your own custom control.
in this article i will show you generating charts using generic handler.
Steps
- Create a new asp.net web project.
- add a new drop down list and bind the list of chart types.
- and a new generic handler by right click on project -> add new item -> select generic handler -> name it as ViewImage.ashx.
- Add chart control by downloading it from here or you can add from extension manager in visual studio 2010 as shown below.
- Add the following the code in ViewImage.
- Add jquery code in default.aspx page.