Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用javascript从DataList EditItem模板获取文本框id?_Javascript_C#_Asp.net - Fatal编程技术网

如何使用javascript从DataList EditItem模板获取文本框id?

如何使用javascript从DataList EditItem模板获取文本框id?,javascript,c#,asp.net,Javascript,C#,Asp.net,我试图添加谷歌地图位置自动完成,但我没有找到文本框id。 我在datallist edititem模板中有textbox控件。在datalist之外,它工作得很好,但是从datalist edititem模板如何获取文本框id google.maps.event.addDomListener(窗口'load',函数(){ var places=new google.maps.places.Autocomplete(document.getElementById(“”); google.maps

我试图添加谷歌地图位置自动完成,但我没有找到文本框id。 我在datallist edititem模板中有textbox控件。在datalist之外,它工作得很好,但是从datalist edititem模板如何获取文本框id

google.maps.event.addDomListener(窗口'load',函数(){

var places=new google.maps.places.Autocomplete(document.getElementById(“”);
google.maps.event.addListener(places,'place_changed',函数(){
var place=places.getPlace();
var address=place.formatted\u地址;
var latitude=place.geometry.location.A;
var经度=place.geometry.location.F;
//var mesg=“地址:”+地址;
//mesg+=“\n纬度:”+纬度;
//mesg+=“\n长度:”+经度;
//警报(mesg);
});
});


地点:
电话:
更新
取消

为文本框指定一个唯一的类名并绑定到该类名。或者使用
ClientIDMode=“Static”
,即使在不起作用的类名中也是如此
        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>