mercredi 13 novembre 2019

Get value from input checkbox tag from bootstrap in .NET

I'm trying using checkbox from Bootstrap (devoops.me) with asp.

On page I have:

<div class="row">
    <div class="col-lg-12">
        <div class="checkbox">
            <label>
                <input type="checkbox" name="testme" />some text for checkbox to choose
                <i class="fa fa-square-o"></i>
            </label>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/><br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
</div>

on server side:

protected void Button1_Click(object sender, EventArgs e)
    {
        HtmlInputCheckBox chk = (HtmlInputCheckBox)this.Form.FindControl("testme");
        if (chk.Checked == true)
        {
            Label1.Text = "YES it's checked";
        }
    }

but all i get is null.

I don't want to use jQuery or javascript. Is is posibble?

Could anybody help me... :)




Aucun commentaire:

Enregistrer un commentaire