How to call c# button click method from javascript?
<p>i am trying to call a server side button click method from javascript function but it's not working, can i know where i did wrong?</p>

<p><strong>aspx code:</strong></p>

<pre><code>&lt;asp:Button ID="ButtonFns" Name="ButtonFns" runat="server" Text="Finish" 
            OnClientClick ="CountDownTick()" class="finish" onclick="ButtonFns_Click" /&gt;
</code></pre>

<p><strong>Javascript code:</strong></p>

<pre><code>function CountDownTick() {
if (_currentSeconds &lt;= 0) {
    document.getElementById('&lt;%= ButtonFns.ClientID %&gt;').click();        
return;
}   
SetCountdownText(_currentSeconds-1);
window.setTimeout("CountDownTick()", 1000);
}
</code></pre>

<p><strong>C# button click:</strong></p>

<pre><code>protected void ButtonFns_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Examination.mdf;Integrated Security=True;User Instance=True");
    try
    {
        con.Open();
        string snm;
        string Em;
        string Sx;
        string uname = Session["status"].ToString();
        string qry = "SELECT SName,Email,Sex FROM Students WHERE Uname=@uname";
        SqlCommand cm = new SqlCommand(qry, con);
        cm.Parameters.AddWithValue("@uname", uname);
        SqlDataReader reader = cm.ExecuteReader();
        while (reader.Read())
        {
            snm = reader["SName"].ToString();
            Em = reader["Email"].ToString();
            Sx = reader["Sex"].ToString();
            if (snm != null &amp;&amp; Em != null &amp;&amp; Sx != null)
            {
                Session["snm"] = snm.ToString();
                Session["em"] = Em.ToString();
                Session["sx"] = Sx.ToString();
                Session["uname"] = uname;
                Session["RAns"] = LabelRitAns.Text;
                Session["Tatt"] = LabelTotAtt.Text;
                Server.Transfer("YourScore.aspx");
                break;
            }
        }

    }
    catch (Exception emsg)
    {
        LabelErr.Text= emsg.Message.ToString();
    }
    finally
    {
        con.Close();
    }

}
</code></pre>

<p>Any help would be appreciated..</p>
