Try the following:
ASPX MARKUP
Make sure
onclick="btnTest_Click"
exists
<asp:Button ID="btnTest" runat="server" Text="Click Me" OnClientClick="testJSfunc();" onclick="btnTest_Click"/>
JavaScript
<script type="text/javascript">
function testJSfunc() {
alert('TEST');
__doPostBack('btnTest', 'OnClick');
}
</script>
CODE BEHIND
protected void btnTest_Click(object sender, EventArgs e)
{
}
Let me know if you have any trouble.
[UPDATED]
If you want to execute the function twice only then apply the following code:
<script type="text/javascript">
var clickCount = 0;
function testJSfunc() {
if (clickCount < 1) {
alert('TEST');
// __doPostBack('btnTest', 'OnClick');
document.getElementById('<%=btnTest.ClientID %>').click();
}
clickCount = clickCount + 1;
}
</script>