I am using a webmethod in asp.net by which some array is returned and by a loop the array data is appended in dropdownlist by jquery.
If the dropdownlist is empty(means no data returned by query of web method),my save button click event is working,but when there is some data returned and bound to the dropdownlisat,button click is not working.
Why this strange behavious is occuring?
function loadCi() {
var catid = $("#drpiccategory").val();
var envid = $("#drpicenvironment").val();
$.ajax({
type: "POST",
url: "incidentnewform.aspx/loadCIFiltered",
data: JSON.stringify({ catid: catid, envid: envid }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var rest = $('#drpAffectedCI');
rest.empty();
var listitems = "";
$.each(data.d, function (index, item) {
rest.append("<option value='" + item.split('~')[0] + "'>" + item.split('~')[1] + "</option>");
});
},
failure: function (response) {
alert("Some error occurred...");
}
});
My button was in update panel,show cann't see the problem.Now I have kept the button outside updatepanel and after postback,this eror shows---------------------
Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true"> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Everyone saying that client side update of a dropdownlist is not allowed in asp.So it is showing error.
But in that case,if this is true,then why json and jquery is developed?I'm fetching data from database by webmethod and json and adding them in dropdownlist by jquey loop so that my process becomes fast.The data is shown correct in the dropdownlist. But button click creating problem.