asp:ModalPopupExtender pop up as update panel which has a 2 dropdown box state , district. once state is selected, district dropdown need to get the selected state's district values to 2nd dropdown
$(document).ready(function () {
function loadDistricts() {
var selectedState = $('#<%= ddlState.ClientID %>').val();
if (selectedState) {
$.ajax({
type: "POST",
url: "QAComplaints.aspx/GetDistricts",
data: JSON.stringify({ state: selectedState }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var districts = response.d;
var districtDropdown = $('#<%= ddlPlace.ClientID %>');
districtDropdown.empty();
districtDropdown.append($('<option></option>').val('').text('--Select--'));
$.each(districts, function (index, district) {
districtDropdown.append($('<option></option>').val(district.District).text(district.District));
});
$('.selDist').selectpicker('refresh');
},
error: function () {
alert('Error loading districts');
}
});
}
}
<WebMethod>
Public Shared Function GetDistricts(state As String) As List(Of District)
Dim jsonFilePath As String = "/Content/Location.json"
Dim jsonData As String = File.ReadAllText(jsonFilePath)
Dim locationData As Dictionary(Of String, List(Of District)) = JsonConvert.DeserializeObject(Of Dictionary(Of String, List(Of District)))(jsonData)
If locationData.ContainsKey(state) Then
Return locationData(state)
Else
Return New List(Of District)()
End If
End Function