Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Html Server Input Checkbox Control CS
1. 1
HTML SERVER CONTROL -InputCheckbox (CS)
LAB WORK GUIDE
"Checkboxes are used for instances where a user may wish to select
multiple options, a sort of check all that apply question. ."
A Programme Under the compumitra Series
4. 4
INPUTCHECKBOX IN HTML CONTROLS -Copy Code and Create your own
Paste it on Notepad and Save this Notepad with
<HtmlInputCheckboxCS.aspx> name in C:/Learner/<student-
id>/HTMLControls/HtmlInputCheckbox folder.
<%@ Page Language="C#"
Debug="true" %>
<script runat="server">
protected void submit(Object sender,
EventArgs e)
{
if(red.Checked == true)
{p1.InnerHtml="You prefer red!";}
else
{p1.InnerHtml="You prefer blue!";}
red.Checked=false;
blue.Checked=false;
}
</script>
<html>
<body>
<form runat="server">
What color do you prefer?
<br />
<input id="red" type="checkbox"
runat="server" />
Red<br />
<input id="blue" type="checkbox"
runat="server"/>
Blue<br />
<input type="button" value="Submit"
OnServerClick="submit" runat="server"/>
<p id="p1" runat="server" />
</form>
</body>
</html>
5. 5
INPUTCHECK BOX IN HTML CONTROLS-Run Your Own Code
For executing this Html file –
Write this Address on address bar.
http://Localhost/<StudentID>/HTMLControls/HTMLInputCheckbox/HTMLInpu
tCheckboxCS.aspx
And after that, click go button.
Output On Browser
6. 6
Add the following code to return condition for
both checked before the else statement.
if (blue.Checked==True)
{
p1.InnerHtml="You prefer both red! and blue!";
}
Watch the effect now.
INPUTCHECK BOX IN HTML CONTROLS-Modification Trials
7. 7
Change protected void submit(Object
sender,EventArgs e) line to
Sub submit(Source As Object, e As EventArgs)
Watch the compiler error output as
CS1026:)expected
INPUTCHECK BOX IN HTML CONTROLS-Error Trials
8. 8
INPUTCHECK BOX IN HTML CONTROLS: Practice Exercise
Write a program which display three Checkboxes 'Red',
'Blue' and 'Green' and one Button 'Submit'. Now write
some conditions to display following output-
If Red and Blue Checkbox is selected the Output is-
You prefer Red and Blue.
If Red and Green Checkbox is selected the Output is-
You prefer Red and Green.
If Blue and Green Checkbox is selected the Output is-
You prefer Blue and Green.
If all the Checkboxes are selected or not and if only one
checkbox is selected the Output is-
Wrong Selection.
9. 9
INPUTCHECK BOX IN HTML CONTROLS: Learning Summary Review
Use of HTML Check Box Control.
Attributes of Check Box Control.
HTML Input Checkbox
Extra C# code with if endif
10. 10
INPUTCHECK BOX IN HTML CONTROLS: Bibliography
http://msdn.microsoft.com/en-
us/library/31d4thc6(v=VS.71).aspx
http://authors.aspalliance.com/aspxtreme/asp
net/syntax/htmlinputcheckboxcontrol.aspx
http://www.w3schools.com/aspnet/control_ht
mlinputcheckbox.asp
http://www.tizag.com/htmlT/htmlcheckboxes.
php
11. 11
Ask and guide me at
sunmitraeducation@gmail.com
Share this information with as
many people as possible.
Keep visiting www.sunmitra.com
for programme updates.