Click here to Skip to main content
13,056,966 members (43,832 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 29-Jun-12 19:42pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.]

function onChange()
    //call your client side method here
    //create the ajax request to call server side method
            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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170728.6 | Last Updated 30 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100