Calling C# Method Using Javascript
<p>I am trying to access a method in my code behind called "Button1_Click" using Javascript, I think there is something wrong in my code below because currently I have to click twice in order for the method to trigger, one click doesn't trigger the method.</p>

<p><strong>My Test Code:</strong></p>

<pre><code>// Javascript

&lt;script type="text/javascript"&gt;
 function CallMe() { document.getElementById('&lt;%= ButtonHidden.ClientID %&gt;').click(); }
&lt;/script&gt;

// Markup

&lt;asp:Button ID="ButtonVisible" runat="server" Text="Test Button"
  OnClientClick="CallMe();"/&gt;
&lt;asp:Button ID="Button1" runat="server" style="display:none;" Text="Click"
  OnClick="Button1_Click"/&gt;

// Code Behind Method

protected void Button1_Click(object sender, EventArgs e)
{
    Response.Redirect("http://google.com");
}
</code></pre>

<p>Am I missing something?</p>
