0

but I don't know why it doesn't work on my project. I just want to call javascript function when the dropdownlist change selection. I search the web Dropdown using javascript onchange and modified my code but it still doesn't work. Can someone tell me how to I call javascritp with clientID as parameter on dropdownlist change selection. Thanks in advance.

There is my code

<asp:dropdownlist id="dropL" runat="server"   onchange="setNote()"  >    </asp:dropdownlist>


function setNote() {
        alert ('ol');
    }
Community
  • 1
  • 1
user819774
  • 1,456
  • 1
  • 19
  • 48
  • Your question is not clear. What is the issue? You don't show any code that demonstrates the problem. Why do you need to pass a clientId? – Rick S Jul 20 '16 at 19:37
  • please add item inside dropdown list and try again this is worked not an issue. – Sanjay Radadiya Jul 20 '16 at 19:42
  • @Rick S, I used source databind on code behind to bind the data. The control is inside the gird, so I want to get the client id – user819774 Jul 20 '16 at 19:50
  • If you want help you will need to read [this](http://stackoverflow.com/help/mcve) first. – Rick S Jul 20 '16 at 19:51
  • I found the problem. The code is no problem. On the project there is add attribution onchange event on code behind when datagrid itemDataBound. Therefore when I added on the aspx page, it doesn't worked. thanks for your time to respond. – user819774 Jul 20 '16 at 20:09

1 Answers1

0
<asp:dropdownlist id="dropL" runat="server"   >    </asp:dropdownlist>



document.querySelector('#dropL').addEventListener("change", setNote);
function setNote() {
        alert ('ol');
 }
Nver Abgaryan
  • 621
  • 8
  • 13