Aditya Sardeshpande
Aditya Sardeshpande

Reputation: 1

How do i use an asp.net variable value in javascript

i have a asp.net application. It is assumed that every Bus has a android device which continuously sends its current location to wcf rest service. Now the administrator on the other side needs to monitor the current location of theses buses. I have a dropdow list from where he chooses the bus number. now i need to send this bus number to the wcf service and show the current location on the map I have no clue as to how do i do this. please help. The plotting algorithm is in javascript and i need to use the asp.net variable in java script to plot the current loacation.

Upvotes: 0

Views: 240

Answers (1)

st mnmn
st mnmn

Reputation: 3667

to get the dropdownlist value use this code:

    var ddl= document.getElementById("<%= yourDDLId.ClientID %>")
    var select= ddl.options[ddl.selectedIndex].text;

and sometimes it works also if you write only:

    var ddl= document.getElementById("yourDDLId")
    var select= ddl.options[ddl.selectedIndex].text;

Upvotes: 1

Related Questions