I fill the treeview with an object that contains id and its value, so it looks like this:
var serializer = new JavaScriptSerializer();
var rslt = serializer.Serialize(new {
Id = node.Id.ToString(),
impactLength = node.impactLenght.ToString()
});
TreeNode newNode = new TreeNode(node.Name, rslt);
I”m having a problem getting its object back from href links of each node:
Here are some examples of hrefs:
1.Root
javascript:__doPostBack('ctl00$ContentPlaceHolder1$treeViewActions','s{\"Id\":\"0\",\"impactLength\":\"1\"}')
2.It’s Descendant
javascript:__doPostBack('ctl00$ContentPlaceHolder1$treeViewActions','s{\"Id\":\"0\",\"impactLength\":\"1\"}\\{\"Id\":\"2\",\"impactLength\":\"1\"}')
I successfully retrieve the href above and get only the object string part
{"Id":"0","impactLength":"1"}{"Id":"2","impactLength":"1"}{"Id":"7","impactLength":"1"}
but when i try to parse it with jQuery.parseJSON, i get an exception:
“Uncaught SyntaxError: Unexpected token {“
What am i doing wrong?
thanks,
Eddie
To process them all at once, you’d need to build them into the Array notation of JSON.
As it is, it isn’t valid JSON markup. You should really send the data from the server as proper JSON.
If you can’t change it on the server side, then you could try this, but no guarantees: