Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
this is my java script function
C#
function OnClientSeriesClicked(sender, eventArgs)
      {
          eventArgs.get_dataItems();
      }


this is my C# code
C#
chrtPie.OnClientSeriesClicked += new EventHandler(OnClientSeriesClicked());
         chrtPie.Legend.Appearance.Visible = true;
         chrtPie.Legend.Appearance.Position = ChartLegendPosition.Left;
         chrtPie.Legend.Appearance.TextStyle.FontFamily = "sans-serif";
         chrtPie.Legend.Appearance.TextStyle.FontSize = 12;

         chrtPie.Height = 50;
         chrtPie.Width = 50;

     private  EventHandler OnClientSeriesClicked()
     {
     //from here i want to call that javascript function
     }


here this radhtml chart is created dynamically.
So any one can help me?
Thanks in advance.
Posted

May be you can do something like this-

C#
//find out sender
//find out eventArgs
Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "OnClientSeriesClicked("+sender+","+eventArgs+");", true);
 
Share this answer
 
You can write java script from backend in C#. In this way you can pass your variable in java script function.

Look at the link:
http://stackoverflow.com/questions/19288428/how-to-write-this-javascript-coding-in-c-sharp-code-behind
 
Share this answer
 
C#
Page page = HttpContext.Current.CurrentHandler as Page;
 page.ClientScript.RegisterStartupScript(typeof(Page), "Test", "<script type='text/javascript'>functionname1(" + arg1+ ",'" + arg2+ "');</script>");

More:
Call Javascript function from C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900