Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET4.0
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 29-Jun-12 20:42pm

1 solution

Rate this: bad
good
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
    $.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
        }
    );
 
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 30 Jun 2012
Copyright © CodeProject, 1999-2014
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