How can I call a javascript function when Checkbox is checked
<p>How can I call a Javascript function when a checkbox is checked when this checkbox is inside a gridview ?</p>

<pre><code>protected void AlteraStatusExpiraSeteDias_Click(object sender, EventArgs e)
{
    for (int i = 0; i &lt; grdImoveis2.Rows.Count; i++)
    {
        GridViewRow RowViewExpiraSeteDias = (GridViewRow)grdImoveis2.Rows[i];
        CheckBox chk = (CheckBox)grdImoveis2.Rows[i].FindControl("chkExpiraSeteDias");
        if (chk != null)
        {
            String codigo;
            if (chk.Checked)
            {
                codigo = (String)grdImoveis2.Rows[i].Cells[0].Text;                        
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Registra", "AlteraStatus(codigo);", false);
            }
        }
    }
}



&lt;asp:GridView ID="grdImoveis2" CssClass="StyleGrid" Width="100%" runat="server" AutoGenerateColumns="false" DataSourceID="ds" BorderWidth="0" GridLines="None"&gt;
    &lt;AlternatingRowStyle BackColor="White" CssClass="EstiloDalinhaAlternativaGrid"  HorizontalAlign="Center"/&gt;
        &lt;RowStyle CssClass="EstiloDalinhaGrid" HorizontalAlign="Center" /&gt;
        &lt;HeaderStyle BackColor="#e2dcd2" CssClass="thGrid" Height="20" /&gt;
    &lt;Columns&gt;
        &lt;asp:BoundField HeaderText="Código" DataField="Imovel_Id" /&gt;
        &lt;asp:BoundField HeaderText="Para" DataField="TransacaoSigla" /&gt;
        &lt;asp:BoundField HeaderText="Valor" DataField="ValorImovel" DataFormatString="{0:c}" HtmlEncode="false" /&gt;
        &lt;asp:TemplateField HeaderText="Endereco"&gt;
            &lt;ItemTemplate&gt;
                &lt;%# Eval("Logradouro") %&gt;, &lt;%# Eval("Numero") %&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:BoundField HeaderText="Data Cadastro" DataField="DataHora"  DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="false"/&gt;
        &lt;asp:BoundField HeaderText="Data Expira" DataField="DataExpira"  DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="false"/&gt;
        &lt;asp:TemplateField HeaderText="Ação"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID="chkExpiraSeteDias" runat="server" onclick="alert('Foo')" /&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>Without the checkbox, when I put a image and put a link href to the javascript, it's works!, but with checkbox, no!</p>
