我正在转换纬度和经度的地址。
这是我的所有代码
<script type="text/javascript">
function codeAddress() {
if (Page_ClientValidate()) {
var address = $(".Hno").val() + " " + $(".Address").val() + "," + $(".City").val();
try {
// Fetch Lattitude and logtittude for Using Google Map
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
console.log(results[0]);
var location = results[0].geometry.location;
$('[id*=hdnLat]').val(location.lat());
$('[id*=hdnLng]').val(location.lng());
javascript: __doPostBack('cMiddle1$btnUpdate', '');
}
else {
alert("Please putt the address info correctly");
}
});
return false;
}
catch (err) {
alert(err);
}
}
}
</script>
这是链接按钮
<asp:LinkButton ID="btnUpdate" runat="server" CssClass="btn" Text="Submit" CausesValidation="true" ValidationGroup="ERegister" OnClientClick="return codeAddress();"></asp:LinkButton>
当页面呈现时,会声明onclick事件
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
我在__dopostback之前提醒纬度和经度,警报工作正常。但__dopostback无效。