In this article I will explain with an example, how to check whether CheckBox is checked or not in ASP.Net using C# and VB.Net.
When the Button is clicked, the status of CheckBox i.e. whether the CheckBox is checked (selected) or unchecked (unselected) is displayed using JavaScript Alert Message Box with C# and VB.Net.
 
 
HTML Markup
The following HTML Markup consists of a CheckBox and a Button. The Button has been assigned an OnClick event handler.
<asp:CheckBox ID="chkPassport" Text="Do you have Passport?" runat="server" />
<br />
<br />
<asp:Button ID = "btnCheck" Text="Check" runat="server" OnClick = "ButtonClicked" />
 
 
Checking whether CheckBox is checked or not in ASP.Net using C# and VB.Net
Inside the ButtonClicked event handler, a JavaScript Alert Message Box will be displayed which displays whether the CheckBox is checked (selected) or unchecked (unselected).
C#
protected void ButtonClicked(object sender, EventArgs e)
{
    if (chkPassport.Checked)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('CheckBox checked.');", true);
    }
    else
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('CheckBox not checked.');", true);
    }
}
 
VB.Net
Protected Sub ButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
    If chkPassport.Checked Then
        ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('CheckBox checked.');", True)
    Else
        ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('CheckBox not checked.');", True)
    End If
End Sub
 
 
Screenshot
Check whether CheckBox is checked or not in ASP.Net using C# and VB.Net
 
 
Demo
 
 
Downloads