asp.net - Sending a Dictonary Key to JS function -
I am trying to send a diction key (which is the string) in the javascript function
& Lt; TR & gt; & Lt; TD & gt; & Lt; A href = "#" onclick = "javascript: editing field (& lt;% = field.Key%>)" & gt; & Lt;% = Html.Encode (field.Value.Name)%> & Lt; / A & gt; & Lt; / TD & gt; & Lt; TR & gt; & Lt;%}% & gt;
But, on the Javascript function, I get it as an object in which I have a 'femme' object. I do not get it as a string.
My JS function looks like this -
function EditField (field) {// blah blah}
But is there a 'gatta' when sending dictary keys?
You could only pass simple types like strings and integers near the JavaScript function. If you want to pass complex objects you will need to encode JSON. In your case you have not mentioned the .NET type of your dictionary key, but if this is a string then you have to put it between quotation marks and do not forget to convert it to HTML encode:
< Code> & lt; A href = "#" onclick = "javascript: editing field ('<% = html.Encode (field.key)%> gt;')" & gt;
Comments
Post a Comment