Click here to Skip to main content
15,171,576 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want pass the dropdownlist selected value to webmethod using ajax

What I have tried:

var liste = document.getElementById('#ddlList');
var ddl = liste.options[liste.selectedIndex].value;


this is not work
Posted
Updated 3-Aug-16 4:09am
Comments
Animesh Datta 3-Aug-16 8:12am
   
First put a break point in web method and check whether the break point is reaching or not . if not then paste the code where you are passing dropdown selected value using ajax method.

If you google "jquery selected value from dropdown" you'll find many, many answers very easily.

Do this:
JavaScript
var selectedVal = $('#dropDownid').val();
   
Comments
Nethaji chennai 3-Aug-16 7:58am
   
i tried this also not working for me. this value pass to webmethod
ZurdoDev 3-Aug-16 7:59am
   
Then you'll have to post what you are doing because that does work.
Nethaji chennai 3-Aug-16 8:43am
   
<asp:DropDownList ID="ddlsec" runat="server" onchange="selesectiondrop(this)">




var liste = document.getElementById('#ddlsec');
var selectedVal = $('#ddlsec').val();
alert(selectedVal);
ZurdoDev 3-Aug-16 8:47am
   
So, debug it. What is $("#ddlsec").length? Is this inside a control or master page? If so, then the actual client id will not be ddlsec, but will have stuff added to the front.
Nethaji chennai 3-Aug-16 8:42am
   
<asp:DropDownList ID="ddlsec" runat="server" onchange="selesectiondrop(this)">




var liste = document.getElementById('#ddlsec');
var selectedVal = $('#ddlsec').val();
alert(selectedVal);
Nethaji chennai 3-Aug-16 8:42am
   
drodown list bind using ajax
use client ID[^]

JavaScript
var value =  $('#<%=ddlList.ClientID%>').val();
   
Comments
Nethaji chennai 3-Aug-16 9:26am
   
i got it thanks for help
Karthik_Mahalingam 3-Aug-16 9:28am
   
welcome

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