How to get results from javascript in .NET

after long surfing through google i hope someone can give a good answer.

Here I have javascript that 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 line in .NET that I can work with?

I tried using JINT ( http://jint.codeplex.com/ ), but when I run the script, it returns the type of the object to me and I can not do anything with this ...

I need to get the data with some changes in the javascript data source. This is not a JSON obj, so I cannot parse it.

Any suggestions?

thanks

+4
source share
2 answers

If you have a properly formed JSON object stored on the clipboard (which, I assume, is the transport that you will use to send to your server), you can create the object through the "Insert Special" function under which it will generate the corresponding a class in .NET to store this object, for example

enter image description here

This also works for XML objects.

+4
source

You can save these values ​​in 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 the codebehind file you can access the hidden field

 hiddenField1.Value; 
+1
source

All Articles