Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Bind Dropdownlist Using Javascript but I Want To call dropdownlist selected index change event But Invalid postback or callback argument error Are Occured please Give Any Solution
Posted

You could do this indirectly; from your Javascript you should invoke by using AJAX a new method on your server by passing it the selected index,then that new method will could manage directly the index change event or could invoke your existing select index changed method.
Here is an example of Javascript that use AJAX call for a dropdownlist:

function CartAddressChanged() {
        var address = $("#_addressTypeDropDown").val();
        $.ajax({
            type: "POST",
            url: "/Order/CartForNewAddress",
            data: "address=" + address,
            success: function () {
                document.location = "/Order/ShoppingCart";
            },
            error: function (jqXHR, exception) {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }); //end ajax call
        return false;
    };
 
Share this answer
 
is this what you need?
DropDownList1.DataSource = sourceName;
DropDownList1.DataValueField = "value";
DropDownList1.DataTextField = "text";
DropDownList1.DataBind();
DropDownList1.Attributes.Add("onChange", "functionName(this);");
 
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