Reputation: 3418
I have an <asp:DropDownList>
element filled with items, where each item represents an application name. I would like to pass a hidden value (the url of the application be specific) for each of these items. I need the value in my Javascript code. I think my code would look better if I prevent the operation of having to query the database using an ajax call.
Is it possible to hide multiple values for each item in a dropdownlist? If so, how?
Upvotes: 0
Views: 218
Reputation: 1520
In codebehind:
Use the Newtonsoft.Json library to convert data into a JSON object https://dotnetfiddle.net/tMXHsI
Set an <asp:HiddenField>
value with that content.
On the page, in javascript:
var myURLs = JSON.parse( HiddenField.value );
You now have a javascript object that you can pull data from.
Upvotes: 1