In order to activate a button event, you need to insert the following line of code in your javascript.
document.getElementById("btn_newpl").click();
Your button should include attributes runat="server"
and OnServerClick="btn_newpl_Click"
.
If you encounter an issue where the input
element is within a javascript string, you can retrieve the string value of the input
and concatenate it with your string on the client side.
<input type="button" id="btn_newpl" value="submit"
OnServerClick="btn_newpl_Click"
runat="server" />
<script>
var tmp = document.createElement("div");
tmp.appendChild(document.getElementById('btn_newpl'));
google.maps.event.addListener(marker, "click", function (e) {
var infoWindow = new google.maps.InfoWindow({
content:
'<div><input type="text" id="txt_newpl" value="place name"/>' +
'</br>'+tmp.innerHTML+'</div>'
})
});
</script>
Please be aware that you are not directly calling a C# function, but simply triggering the click event on web forms which results in a postback to the server. The server will detect the triggered event and execute the corresponding C# function.
Source: How to call a code behinds button click event using javascript