如何将cson变量从cs文件发送到htm / javascript文件 [英] How to send a Json variable from a cs file to htm / javascript file
问题描述
我有一个数据集列表,其中包含我已经执行过的查询结果,并且使用JsonConvert.SerializeObject我可以创建一个json变量。
知道我想在javascript或html文件中读取这个变量,所以我可以使用该数据并将其作为图表呈现,但我不知道如何发送它。
我正在Windows窗体应用程序(visual studio 2010)中开发我的程序,并在单击按钮时调用htm文件。
无论如何都可以吗?
你能给出一些代码示例吗?
thk
I have a list of dataset with the results from queries, that i already have performed, and using JsonConvert.SerializeObject i can create a json variable.
Know i want to read this variable in a javascript or html file so i can use that data and present it as charts, but i don't know how to send it.
i'm developing my program in a windows form app (visual studio 2010) and calling a htm file when clicking a button.
is there anyway to do it?
can you give some code examples?
thk
推荐答案
您可以通过以下两种方式探索。
尝试JavaScriptSerializer
并将JSON作为字符串返回。
或使用反序列化器> DataContractJsonSerializer
- http://msdn.microsoft.com/en-us/library/bb412179%28v=vs.11 0%29.aspx [ ^ ]。
There are a couple of ways you could explore.
TryJavaScriptSerializer
and return JSON as string.
Or deserializer usingDataContractJsonSerializer
- http://msdn.microsoft.com/en-us/library/bb412179%28v=vs.110%29.aspx[^].
这篇关于如何将cson变量从cs文件发送到htm / javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!