将值从javascript解析为C#程序 [英] Parsing a value from javascript to C# program

查看:53
本文介绍了将值从javascript解析为C#程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从我的C#程序中的以下JavaScript解析变量latlong的值?



函数showPosition(position){

var latlon = position.coords.latitude +||+ position.coords.longitude;

}



我的尝试:



我已经尝试使用侏罗纪引擎,但它不支持导航

How can i parse the value of the variable latlong from the following JavaScript on my C# program?

function showPosition(position) {
var latlon=position.coords.latitude+"||"+position.coords.longitude;
}

What I have tried:

I have already tried to use Jurassic Engine but it doesn't support navigation

推荐答案

您可以对其进行编码以将latlon存储到隐藏元素中。示例。



在aspx页面上,添加一个隐藏字段



You can code it to store the latlon into a hidden element. Example.

On the aspx page, add a hidden field

<asp:HiddenField ID="HiddenField1" runat="server" />





然后添加JavaScript





Then add the JavaScript

function showPosition(position) {
   var latlon=position.coords.latitude+"||"+position.coords.longitude;
   document.getElementById("<%=HiddenField1.ClientID%>").value = latlon;
}





然后在后面的代码中,访问隐藏的字段值



Then in the code behind, access the hidden field value

var x = HiddenField1.Value;


这篇关于将值从javascript解析为C#程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆