How to Use a CheckBox Control in Visual Basic.NET
In this tutorial you will learn how to use the CheckBox control. The CheckBox control acts like any check box control you have come across a web site in that it allows the user to select an option. In this tutorial we will pair a CheckBox control with a Literal control that will display
if the check box is selected or not.
Setting Up
If you have not created a web site already, open Visual Studio and click File > New > Web Site to create one. Using ‘Visual Basic’ as the template, select ASP.NET Empty Web Site and click OK.
Step One
Right click the web site name and click Add New Item. Using ‘Visual Basic’ as the template, select Web Form, leave the file name as Default.aspx and click add. Inside the div tags, place a CheckBox, Button, and Literal control. Change the text of the CheckBox to “To Check or Not to Check?” and the Button text to “Submit”.
Switch to design view and double click the button to create an event handler method. Inside this method we will use an if statement that checks if the check box is checked or not. If the check box is checked we will output “You Checked the Box” and if not we will output “You Did Not Check the Box”.

Thanks for reading and make sure to download the source files to get a better understanding of how the code works.
CheckBoxControl-VB.zip
if the check box is selected or not.
Setting Up
If you have not created a web site already, open Visual Studio and click File > New > Web Site to create one. Using ‘Visual Basic’ as the template, select ASP.NET Empty Web Site and click OK.
Step One
Right click the web site name and click Add New Item. Using ‘Visual Basic’ as the template, select Web Form, leave the file name as Default.aspx and click add. Inside the div tags, place a CheckBox, Button, and Literal control. Change the text of the CheckBox to “To Check or Not to Check?” and the Button text to “Submit”.
Code Block
Default.aspx
All controls are from the Toolbox panel.<asp:CheckBox ID="CheckBox1" runat="server" Text="To Check or Not to Check?" />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<br />
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
Yes, it is possible to find a good web host. Sometimes it takes a while to find one you are comfortable with. After trying several, we went with Server Intellect and have been very happy thus far. They are by far the most professional, customer service friendly and technically knowledgeable host we’ve found so far.
Step TwoSwitch to design view and double click the button to create an event handler method. Inside this method we will use an if statement that checks if the check box is checked or not. If the check box is checked we will output “You Checked the Box” and if not we will output “You Did Not Check the Box”.
Code Block
Default.aspx.vb
Button1_Click event method.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
Literal1.Text = "You Checked the Box"
Else
Literal1.Text = "You Did Not Check the Box"
End If
End Sub
Need help with cloud hosting? Try Server Intellect. We used them for our cloud hosting services and we are very happy with the results!
Output
Thanks for reading and make sure to download the source files to get a better understanding of how the code works.
CheckBoxControl-VB.zip
