This Control is used to provide the selection of two or more options from the given group of options
Properties of checkbox Control:
AutoPostBack:
- When set to true page request is submitted as PostBack to server, when default Event that CheckedChanged is fired
- When set to false page request will not be submitted to the server when default Event that CheckedChanged is fired
CheckedProperty:
- Stores value of true, when checkbox is activated otherwise stores false
Default Event of checkbox:
- If CheckedChanged this Event is fired when CheckBox is activated otherwise stores false
Example with Checkbox Control:
Create a New WebPage
,Design the web page
- Set the following properties for TextBox1:-
ID --- txtSample
- Set the following properties forCheckBox1:-
DI ---- chkPlayingText ---- PlayingAutoPostBack ---- True
- Set the following properties forCheckBox1:-
ID ---- chkPlayingText ---- PlayingAutoPostBack ---- True
Goto Source and write the following Code
protected void
btnSubmit_Click(object sender, EventArgs e)
{
string
S = txtSample.Text + " Hobbies Are ";
if
(chkBrowsing.Checked == true)
S = S + chkBrowsing.Text + " ";
if
(chkPlaying.Checked == true)
S = S + chkPlaying.Text;
lblDisplay.Text = S;
}
|
Run the WebPage & Check
No comments:
Post a Comment