简体   繁体   English

我如何在JavaScript中使用asp.net变量值

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

i have a asp.net application. 我有一个asp.net应用程序。 It is assumed that every Bus has a android device which continuously sends its current location to wcf rest service. 假定每辆公共汽车都有一个android设备,该设备连续将其当前位置发送到wcf rest服务。 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. 现在,我需要将此总线号发送到wcf服务,并在地图上显示当前位置,但我不知道如何执行此操作。 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. 绘图算法在javascript中,我需要在Java脚本中使用asp.net变量来绘制当前位置。

to get the dropdownlist value use this code: 要获取dropdownlist值,请使用以下代码:

    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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在asp.net按钮中使用javascript变量值单击 - how can i use javascript variable value in asp.net button click 如何使用JavaScript变量在JavaScript函数中获取ASP.NET ClientID? - How can I use a JavaScript variable to get an ASP.NET ClientID inside a JavaScript function? 如何在ASP.NET控件的OnClientClick属性中使用javascript变量 - How to use a javascript variable in the OnClientClick attribute of a ASP.NET control MVC ASP.Net Javascript-如果Url没有ID,如何使用JavaScript函数隐藏按钮 - MVC ASP.Net Javascript - How do I use a javascript function to hide a button if Url has no id 如何获取ASP.net变量的值到JavaScript文本框中 - How to get the value of an ASP.net variable into a javascript textbox 如何从asp.net获取JavaScript中应用程序变量的值? - How to get value of application variable in JavaScript from asp.net? 如何使用asp.net Web表单在javascript中使用vb变量? - How can I use vb variable in javascript using asp.net web forms? 如何在javascript代码和asp.net razor mvc代码中利用相同的变量? - How do I utilize the same variable in both javascript code and asp.net razor mvc code? 如何在ASP.Net MVC中进行JavaScript重定向? - How do I do a JavaScript redirect in ASP.Net MVC? 如何从asp.net核心视图更新javascript中的模型值 - How do I update model value in javascript from asp.net core view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM