So, I have a button and I want to click on it via JavaScript. My code is
<button ID="btnTransfer" OnClick="return submeterBotao()">Submeter</button>
<asp:Button runat="server" id="submeterButton" OnClick="submeter"/>
<script>
function submeterBotao() {
var button = document.getElementById("submeterButton");
button.click();
return false;
}
</script>
The submeter() function in C# only Redirect the page. But when I click on Submeter it just refreshes the page.
Can anyone help me? Thanks!
-------UPDATE---------
I just did this
<asp:Button runat="server" id="submeterButton" OnClick="submeter" OnClientClick="submeterBotao()" Text="Submeter Caso"/>
<script>
function submeterBotao() {
alert("I am an alert box!");
}
</script>
and it seems to work just fine!