Click here to Skip to main content
15,884,783 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi Good morning!!!
i Have a problem .i wanna call a sever side method and one Javacsript method on Selected index change on dropdownlist on same time.if acll clent side method then not acll sever side method.please help
Posted

1 solution

I think you can. althogh you will have to decide which one will be executed first.

1. create the dropdown
2. handle the change event on client side and call a function like OnChange();
3. in this onchange function call your client side function.
4. in the same function call the server side function using XMLHttpRequet or jQuery AJAX.

the following article already decribes how to call server side function

AJAX for beginners (Part 2) - Using XMLHttpRequest and jQuery AJAX to implement a cascading dropdown[^]

I suggest you make a small change like: [Code snippet from above article, refer that for details.]

JavaScript
function onChange()
{ 
    //call your client side method here
   
    //create the ajax request to call server side method
    $.ajax
    ( 
        {
            type: "POST", //HTTP method
            url: "Default2.aspx/OnContinentChange", //page/method name
            data: "{'continentName':'"+$('#drpContinent').val() +"'}", //json to represent argument
            contentType: "application/json; charset=utf-8", 
            dataType: "json",
            success: callback,
            error: onError
        }
    );

}
 
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