This is a migrated thread and some comments may be shown as answers.

I can't get OnClick to fire for RadChart with MVC

1 Answer 43 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Kelly Hamilton
Top achievements
Rank 1
Kelly Hamilton asked on 27 Aug 2012, 03:48 PM
Hello, I've been testing out the RadChart from RadControls for ASP.NET AJAX and I can't get teh OnClick event to fire when I use the chart in an MVC application. It works fine for a non MVC application. In the MVC application all other event seem to work fine (Init, Load, DataBound,etc). There are a couple of extra steps to get the chart to work on an MVC view which I have followed. The chart displays fine, and I can add the OnCLick with the designer, but when I click on the chart, there is a post back, but the event handler doesn't execute.
I'm using version 2012.2.815.40 on Windows 7 64 bit with Visual Studio 2010.

To Reproduce this, I just made a brand new ASP.NET MVC 2 template application with a test project.
- I added this to the Webconfig:
under <system.web>
        <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
        <add verb="*" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" validate="false" />


    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers accessPolicy="Read, Script">
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ChartHandler" path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI" />

I updated the Global.asax.cs as follows:

  public static void RegisterRoutes(RouteCollection routes)
   routes.IgnoreRoute("{controller}/{resource}.axd/{*pathInfo}"); // This is new
   routes.IgnoreRoute("{controller}/{action}/{resource}.axd/{*pathInfo}"); // This is new

    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults


Then I added a RadChart to the About view and bound it to an XML data file containing:

<?xml version="1.0" encoding="utf-8" ?>
   <person name="Brown, William" all="20" some="50" few="25" notassessed="5"  />
  <person name="Edwards, Kimberly" all="30" some="45" few="20" notassessed="5"  />
  <person name="Evans, Sarah" all="80" some="10" few="5" notassessed="5"  />
  <person name="King, Elizabeth" all="25" some="35" few="35" notassessed="5"  />
  <person name="White, Mark" all="50" some="20" few="10" notassessed="20"  />


Then I added the click hander and DataBound handler to the chart.

Then when I run the application and show the About view, The chart shows, but the click handler is not called, but other event handlers are called.

Any help would be appreciated,Thanks,

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 Aug 2012, 02:31 PM
Hi Kelly,

Postback is not part of the ASP.NET MVC paradigm, so I am afraid RadChart.Click event will not work in MVC. Actually, this is true for Button.Click too. You can find it discussed in different forums e.g. here.

Best regards,
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Chart (Obsolete)
Asked by
Kelly Hamilton
Top achievements
Rank 1
Answers by
Telerik team
Share this question