RSS

Search Engine

Wednesday, May 19, 2010

ASP.Net RadioButton Control

The ASP.Net RadioButton control provides the functionality to display an individual radio button on the Web form that returns the true or false type Boolean value as a result. If the RadioButton control is in selected state then it returns true and if it is in unselected state then the radio button returns false. You can display a group of multiple radio buttons on the web page to provide a mutually exclusive set of options to the users. Users can select one of the radio buttons from the group to specify their choice. You can perform the server side action based on the selection made by the user that can detected by getting the value of checked property of each radio button displayed as a member of the group.

Properties of ASP.Net RadioButton Control

Following are the properties of ASP.Net RadioButton control to get or set its value or behavior on the web page:

1. Checked: It gets or sets the radiobutton state. If the radio button control is in selected state then checked property returns true otherwise it returns false. The Checked property of radio button control accepts and returns Boolean value.

2. AutoPostBack: If you want to execute the PostBack event of radio button control when user changes its state to selected state. The AutoPostBack property also accepts the Boolean value i.e. true or false to allow or disallow the PostBack event of radio button control.

3. GroupName: It accepts the string value as a name for the group of radio buttons to create a list of mutually exclusive set of options. Multiple radio buttons specified with same GroupName allows to select only one radio button option.

4. Text: It allows you to display the label with a text string next to the radiobutton control. You can specify a string value for the text property of radio button control.

5. TextAlign: It enables you to adjust the alignment of the text value specifvied to the Text property of the radio button. You can align the specified text to the left or right side of the radio button.

The RadioButton control consists of following PostBack event that can be handled at server side to execute the server code and perform the speciifed action according to the selected radio button control:

CheckedChanged Event: It enables you to handle the PostBack event of radiobutton control when user changes its state from selected state. When user clicks the radio button it raises the CheckedChanged event only if the AutoPostBack property of RadioButton control is set to true.

The radio button control is an ASP.Net web server control when it is rendered on the web page it splits up into two parts:

1. HTML input control having "type" attribute value as "radio".

2. HTML label control to display the string specified for the text property of radio button server control.

0 comments:

Post a Comment