0
私はC#の初心者です。C#asp.netのJavascript関数から変数を取得する方法
質問:JavaScriptの関数compute_shape_area()
から変数area
を取得しようとしていますが、C#asp.netでどのように実装するのですか?どうもありがとう。
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body onload="compute_shape_area()">
<p id="area1"></p>
<script>
var Obj_shape;
function initMap() {
var request = new XMLHttpRequest();
request.open('GET', 'http://localhost:8080/shape.txt');
//GET Data and build Obj_shape
request.send();
}
function compute_shape_area(){
var area = parseFloat(google.maps.geometry.spherical.computeArea(Obj_shape.getPath()));
area = area.toFixed(4);
document.getElementById("area1").innerHTML = area;
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=APIKey&callback=initMap"></script>
</body>
</html>
を??ここでエラーが発生しました:名前 'yourJsVariable'は現在のコンテキストに存在しません –
私の答えの@HenryWenHanLeeコードは、プリンシパルを表示するための例です。実際のコードアプリケーションを使用して変更する必要があります。あなたのケースではasp:HiddenFieldをポストバックで取得することを検討してください – GibboK