我正在尝试添加谷歌地图自动填充,但我没有找到文本框ID。 我在datallist edititem模板中有文本框控件。在datalist之外,它工作得很完美,但是从datalist edititem模板获取Textbox id。
google.maps.event.addDomListener(窗口,'加载',函数(){
var places = new google.maps.places.Autocomplete(document.getElementById("<%= txtAddress.ClientID %>"));
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var address = place.formatted_address;
var latitude = place.geometry.location.A;
var longitude = place.geometry.location.F;
//var mesg = "Address: " + address;
//mesg += "\nLatitude: " + latitude;
//mesg += "\nLongitude: " + longitude;
//alert(mesg);
});
});
</script>
<tr>
<td>Location:
</td>
<td class="pro-edit-td ">
<%# Eval("strAddress")%>
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="edit" meta:resourcekey="lnkEditResource1"> <i class="far fa-edit"></i> </asp:LinkButton>
<a></a>
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table class="table">
<tr>
<td>Phone:
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Text='<%# Eval("strAddress") %>' meta:resourcekey="txtAddressResource1"></asp:TextBox>
<asp:LinkButton ID="lnkUpdate" runat="server" CommandName="update" meta:resourcekey="lnkUpdateResource1">Update </asp:LinkButton>
<asp:LinkButton ID="lnkCancel" runat="server" CommandName="cancel" meta:resourcekey="lnkCancelResource1">Cancel </asp:LinkButton>
</td>
</tr>
</table>
</EditItemTemplate>
</asp:DataList>