Asp. NET RadioButtonList the use of radio button Group Control _ Basic Application

Source: Internet
Author: User

The RadioButtonList control represents a list control that encapsulates a set of radio button controls.

You can add radio buttons to a Web page using two types of ASP.net controls: individual RadioButton controls or one RadioButtonList control. Both types of controls allow users to choose from a group of mutually exclusive predefined options. With these controls, you can define any number of radio buttons with labels and arrange them horizontally or vertically.

First, Common properties

Property value function
RepeatDirection horizontal| Vertical Layout direction of item: Horizontal Direction | vertical Wind
RepeatLayout table| Flow Show Way: Table | streamline
Selected true| Falsee is a selected state

Second, the Code demonstration

Front desk radiobuttonlist.aspx

Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codefile= "RadioButtonList.aspx.cs" inherits= "Webcontrols_" RadioButtonList "%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<title></title>
<body>
<form id= "Form1" runat= "Server" >
<div>
Please select not: <asp:radiobuttonlist
Id= "Radlsex" runat= "server" repeatdirection= "horizontal" repeatlayout= "Flow" >
<asp:listitem selected= "True" > Male </asp:ListItem>
<asp:ListItem> Women </asp:ListItem>
</asp:RadioButtonList>
<br/>
<asp:button id= "btnsubmit" runat= "Server" text= "Submit" onclick= "btnSubmit_Click"/>
The sex you choose is: <asp:label id= "lblstate" runat= "Server" ></asp:Label>

</div>
</form>
</body>

Backstage RadioButtonList.aspx.cs

Copy Code code as follows:

Using System;
Using System.Collections.Generic;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;

public partial class WebControls_RadioButtonList:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{

}
protected void btnSubmit_Click (object sender, EventArgs e)
{
Lblstate.text = Radlsex.selectedvalue;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.