This is a HiddenField declaration that is useful for storing a JSON string.
<asp:HiddenField ID="hdnBankStatus" runat="server" />
This is a Dropdownlist ad.
<select id="optStatus" name="optStatus" runat="server"> </select>
These lines initialize a Hiddenfield value with a sorted list (suppose the list contains pairs of key values ββin sorted order), which is then serialized using the JSON serializer
sl = new SortedList(); hdnBankStatus.Value = jsonSerialiser.Serialize(sl);
These strings will use the JSON String Elements one by one and populate the dropdown menu with the values.
$(document).ready(function () { var myOptions = $.parseJSON($('#hdnBankStatus').val()); var mySelect = $('#optStatus'); $.each(myOptions, function (val, text) { mySelect.append( $('<option></option>').val(text).html(val) ); }); }
source share