Home > Backend Development > C#.Net Tutorial > Introduction to common properties and methods of ASP.NET radio button control RadioButton

Introduction to common properties and methods of ASP.NET radio button control RadioButton

高洛峰
Release: 2017-01-11 10:35:49
Original
3864 people have browsed it

1. Common attributes:

(1) Checked attribute: used to set or return whether the radio button is selected. The value is true when selected, and false when not selected.

(2) AutoCheck property: If the AutoCheck property is set to true (default), then when this radio button is selected, all other radio buttons in the group will be automatically cleared. For ordinary users, there is no need to change this attribute and just use the default value (true).

(3) Appearance property: used to get or set the appearance of the radio button control. Appearance.Button makes the radio button look like a command button: when it is selected, it appears to be pressed. When the value is Appearance.Normal, it is the default radio button appearance.

(4) Text property: used to set or return the text displayed in the radio button control. This property can also contain access keys, that is, letters preceded by the "&"

symbol , so the user can select the control by pressing the Alt key and the access key simultaneously.


2. Commonly used events:

(1) Click event: When a radio button is clicked, the Checked attribute value of the radio button will be set to true, and a Click event will occur at the same time event.

(2) CheckedChanged event: When the value of the Checked attribute changes, the CheckedChanged event will be triggered.

The radiobutton in WPF may be different from that in the Web. It does not have attributes such as group. When using, directly put the radiobuttons of the same group into a groupBox or panel, and they will automatically be a group. There are two ways to use it (to determine which one is selected):

First First method:

foreach (Control ctrl in groupBox1.Controls)
{
 if (ctrl is RadioButton)
 {
  if (((RadioButton)ctrl).Checked )
  {
   //添加你需要的操作
  }
 }
}
Copy after login

Second method: Add events in each radiobutton

private void radioButton_CheckedChanged(object sender, EventArgs e)
{
 RadioButton rb=(RadioButton) sender;
 if (rb.Checked)
 {
     //添加你需要的操作                     
    }
}
Copy after login

For more introduction to the common properties and methods of the ASP.NET radio button control RadioButton, please pay attention to PHP Chinese for related articles net!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template