In this article I will explain with an example, how to get the value of the HTML Input CheckBox in ASP.Net Code Behind (Server Side) using C# and VB.Net.
The values of multiple checked HTML Input CheckBoxes will be fetched in ASP.Net Code Behind (Server Side) using Request.Form collection and Name property.
 
 
HTML Markup
The HTML Markup consists of a Form consisting of HTML Checkboxes and an ASP.Net Button.
<label>
    <input type="checkbox" name="Fruit" value="1" />
    Mango
</label>
<br />
<label>
    <input type="checkbox" name="Fruit" value="2" />
    Apple
</label>
<br />
<label>
    <input type="checkbox" name="Fruit" value="3" />
    Pineapple
</label>
<br />
<label>
    <input type="checkbox" name="Fruit" value="4" />
    Papaya
</label>
<br />
<label>
    <input type="checkbox" name="Fruit" value="5" />
    Grapes
</label>
<br />
<br />
<asp:Button Text="Submit" runat="server" OnClick="Submit" />
 
 
Get value of HTML Input CheckBox in ASP.Net Code Behind (Server Side)
When the Button is clicked, the values of the checked (selected) HTML Input CheckBoxes is fetched from the Request.Form collection using the Name property value of the HTML CheckBoxes.
Note: Since all the HTML Input CheckBoxes have same Name value and hence the Value of the checked (selected) HTML Input CheckBoxes is available as comma separated (comma delimited) string in the Request.Form collection.
The values of CheckBoxes that are not checked is not present in the Request.Form collection.
 
C#
protected void Submit(object sender, EventArgs e)
{
    string selected = Request.Form["Fruit"];
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + selected +"');", true);
}
 
VB.Net
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
    Dim selected As String = Request.Form("Fruit")
    ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & selected & "');", True)
End Sub
 
 
Screenshot
Get value of HTML Input CheckBox in ASP.Net Code Behind (Server Side) using C# and VB.Net
 
 
Demo
 
 
Downloads