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

时间:2018-05-02 11:43:24

标签: javascript c# asp.net

我正在尝试添加谷歌地图自动填充,但我没有找到文本框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>

0 个答案:

没有答案