I have issue in accesing drop down item from c# code behind
Scenario: i am modifying drop down based on user selection using jquery/ajax call. while accesing the drop down item from code behind, still it retains old list.
Please help to access updated drop down list from c# code behind.
Sample code
Jquery code :
$.ajax({
type: 'POST',
url: "Search.aspx/LoadNewOptions",
contentType: 'application/json;charset=utf-8;',
dataType: "json",
data: "",
success: function (data) {
$("#dropdown").empty();
$($.parseJSON(data.d)).each(function () {
var Option = $('<option />');
xOption.attr('value', this.value).text(this.label);
$('#dropdown').append(Option);
}
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
C# Code behind code :
dropdown.SelectedItem.Value.Trim() // returns old value
Alternate Solution: Created separate javascript function and store selected item values in hidden variable. No issues in accessing hidden variables from code behind.