Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
heyy...

I have a set of string in a variable ...I want set this variable to a javascript in (C# code behind).... I tried but won't get result ....

Here is My code...


var dataString = "var dataString=\' <chart caption="\"Top" 5="" employees="" for="" mode="hold" />        dataString += " subCaption=\"(Click to slice out or right click to choose rotation mode)\" YAxisName=\"Sales Achieved\" showValues=\"0\" ";

      dataString += "numberPrefix=\"$\" formatNumberScale=\"0\" showPercentInToolTip=\"0\" showLabels=\"0\" showLegend=\"1\">";
      dataString += "<set label="\"Leverling\"" value="\"100524\"" issliced="\"0\"" />";
      dataString += "<set label="\"Fuller\"" value="\"87790\"" issliced="\"0\"" />";
      dataString += "<set label="\"Davolio\"" value="\"81898\"" issliced="\"0\"" />";
      dataString += "<set label="\"Peacock\"" value="\"76438\"" issliced="\"0\"" />";
      dataString += "<set label="\"King\"" value="\"57430\"" issliced="\"0\"" />";
      dataString += "<styles>";
      dataString += "<definition>";
      dataString += "<style type=\"font\" name=\"CaptionFont\" color=\"666666\" size=\"15\" />";
      dataString += "<style type=\"font\" name=\"SubCaptionFont\" bold=\"0\" />";
      dataString += "</definition>";
      dataString += "<application>";
      dataString += "<apply toobject="\"caption\"" styles="\"CaptionFont\"" />";
      dataString += "<apply toobject="\"SubCaption\"" styles="\"SubCaptionFont\"" />";
      dataString += "</application>";
      dataString += "</styles>";
      dataString += "'";



and My Javascript is :-


string Gal = @"<script>
if (GALLERY_RENDERER && GALLERY_RENDERER.search(/javascript|flash/i) == 0)
FusionCharts.setCurrentRenderer(GALLERY_RENDERER);
var chart = new FusionCharts('Charts/Pie3D.swf', 'ChartID', '500', '500', 'false', 'true');

chart.setXMLData('dataString');

chart.render('divChart');
</script>";
ClientScript.RegisterStartupScript(GetType(), "jsdatepic2", Gal);



I want dataString value to javascript....
Posted
Updated 16-Jun-13 20:40pm
v2
Comments
Mahesh Bailwal 17-Jun-13 2:49am    
One of the issue is that you are passing dataString in quotes and please remove quotes and try.

chart.setXMLData(dataString);
aravindnass 17-Jun-13 3:18am    
I didn't get...

I am using javascript in service side....
Mahesh Bailwal 17-Jun-13 3:52am    
What I mean here is that if you will pass dataString like this chart.setXMLData('dataString') inside quotes than javascript will treat datastring as string not as variable and you won't be able to pass value you have appended to dataString.

Please let me know if you need any more clarification.

1 solution

Try this, hope it helps:

Use "<script language="javascript">alert(dataString);</script>"

OR

You can take one "hidden" type field and set is run at = "server".
After that assign value to it using document.getElementById("nameofurcontrol") = value.

Now in C# code, you can easily get this value.
 
Share this answer
 
v2

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