I'm trying to do a click in a html button through javascript, but I can't make it work.
This is the button I'm trying to click with javascript (it works when I click it)
<button id="btnClean" runat="server" type="button" class="btn btn-warning btn-cons m-b-10" onserverclick="btnClean_Click">
<i class="fa fa-trash-o"></i>
<span class="bold m-l-3">Limpar</span>
</button>
This is the button that calls the javascript function:
<button id="btnCreateOS" type="button" class="btn btn-success btn-cons m-b-10" onclick="Clean();">
<i class="fa fa-save"></i>
<span class="bold m-l-3">Criar</span>
</button>
And this is my javascript (it is located under <form> tag in my .aspx page):
<script type="text/javascript">
function Clean() {
document.getElementById("btnClean").click();
}
</script>
And finally, this is the asp method:
public void btnClean_Click(object sender, EventArgs e)
{
CleanFields();
}
Any ideas what I'm doing wrong?
id? Is the post-back invoked?document.getElementById("btnClean").click();will call client event ofbutton