Now that the RadChart control has officially joined the Silverlight party you are probably considering how to incorporate this jewel in all of your web projects. Probably most of you do not have the luxury to start over from scratch and implement pure Silverlight solutions abandoning all of your ASP.NET knowledge and legacy. With this blog post I will try to provide a simple demonstration how you can take advantage of the RadChart for Silverlight and easily add it to your current ASP.NET web applications. You'll also see how you can update some of the chart properties directly from your ASP.NET code.
Let's start with the Silverlight code -- for the sample application I will demonstrate databinding the chart control to ADO.NET data service that exposes the "Category Sales for 1997" view from the Northwind database. I will not go into the details of the auto-generation of the data model and the actual service that exposes it -- you can find all the details in the attached sample application.
Instead I will focus on the Silverlight code that enables RadChart to consume the data service:
Now let's move to the ASP.NET part – I have set up a simple ASP.NET website with a singe page and a user control. As I need to wrap the Silverlight content inside the user control, first I need to add the following register directive in the ASCX file:
This enables me to reference Silverlight content within the respective ASP.NET user control via the asp:Silverlight server control (the Source property for this control is set to the xap output produced by the Silverlight project discussed above):
Basically this is everything that is necessary to display the Silverlight content inside ASP.NET user control. However, let's spice it up a bit and add the option to customize certain properties of the Silverlight chart control directly from ASP.NET code.
There are two steps necessary in order to achieve the desired functionality:
Let's add the option to customize the following properties from ASP.NET code: - The chart title. - The format of the series item labels. - The format of the vertical axis labels.
As discussed above I need to register the Silverlight page for scriptable access and mark three scriptable members like this:
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.