4

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

3
  • Are you using MVC or classic ASP.NET? Commented Apr 29, 2013 at 17:23
  • I am using MVC . Commented Apr 29, 2013 at 17:36
  • Look at the answers and check the right one to close this question. Commented May 5, 2013 at 14:18

2 Answers 2

4

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.

enter image description here

This also works for XML objects.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank it's good for the future, but not what I need. I have just simple javascript text from server response, now I need with out some changing in source ( javascipt) get data from it. It's not json, so it's would works.
1

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;

1 Comment

That's also what I do when I'm not using json, post or query strings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.