Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
JavaScript
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>");
            });
            //alert(listitems);
            //rest.append("<option>test</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.
Posted
Updated 8-Dec-14 7:33am
v3
Comments
Really !!! You must be having some other issue. Please see the Developer Tool console window and rectify if any errors are there.
ZurdoDev 8-Dec-14 13:13pm    
You are likely returning invalid data which is causing the html in your page to be broken such that the click of the button no longer fires.
souvikcode 18-Dec-14 4:31am    
You are right.

1 solution

This is solved.The data returned some invalid argument.I have tested that and corrected the error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900