Reputation: 503
after long surfing via google I hope somebody can give good answer.
Here I have some javascript with I get in .NET C#
<script type="text/javascript">
var itemMap = new Array();
itemMap[0] = {
pid: "20466846",
sku: 13897265,
sDesc: "XSMALL",
sId: "101979",
cDesc: "Black",
cId: "1203740",
avail: "IN_STOCK",
price: "$4.99",
jdaStyle: "60016655"
};
How can I get results from this string in .NET that I can work with it?
I tried to use JINT (http://jint.codeplex.com/) but when I run script it's return for me type of object and I can not do anything with that...
I need with out some changes in javascript source get data. It's not JSON obj so I can not parse it.
Any suggestions?
Thanks
Upvotes: 4
Views: 279
Reputation: 965
You can save these values into hidden fields
<script type="text/javascript">
var hiddenField1 = document.getElementById('hiddenField1');
hiddenField1.value = ???;
</script>
<asp:HiddenField runat="server" ID="hiddenField1" Value="" ClientIDMode="Static" />
and in codebehind file you can access the hidden field by
hiddenField1.Value;
Upvotes: 1
Reputation: 32258
If you have an appropriately formed JSON object stored in the clip board (which I'm guessing is the transport that you'll be using to send to your back-end), you can create an object via Paste Special under the edit menu that will generate the appropriate class in .NET to hold that object, e.g.
This also works for XML objects.
Upvotes: 4