I think you are doing it wrong. You create an element input and then append your textbox to it, after that you try to get value of element input (txt_java.value
), which is wrong, you want value of textbox (document.getElementById('txt_newpl').value
).
<script>
// .. rest of the code ...
document.getElementById("<%= txt_place_name.ClientID%>").value = document.getElementById('txt_newpl').value;
</script>
Also, wouldn't be easy if you add your <asp:TextBox ... />
to the info window to be completed, like this. In this way you won't complicate your code with unnecessary exchange of values.
<asp:TextBox ID="txt_place_name" CssClass="form-control ltr" ValidationGroup="add" runat="server"></asp:TextBox>
<script>
var tmp = document.createElement("input");
tmp.appendChild(document.getElementById("<%= txt_place_name.ClientID %>"));
google.maps.event.addListener(marker, "click", function (e) {
var infoWindow = new google.maps.InfoWindow({
content:
'<div>' + tmp.innerHTML + '</div>'
})
});
</script>
You can do this because <asp:TextBox .../>
control will be rendered to an html element <input type="text" ... />
. This render (transforming) process is happening on sever side.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…