前台代码:

 <div>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName ="sex" Text ="男"/>
<asp:RadioButton ID="RadioButton2" runat="server" GroupName ="sex" Text ="女"/>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick ="Button1_Click"/>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>

*其中,groupName要写上,这个的作用是让其属于同一个组,选了一个,不能选另一个。

后台代码:

 /// <summary>
/// Button1按钮的单机事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
string s = string.Empty; if (RadioButton1.Checked)
{
s += RadioButton1.Text;
}
if (RadioButton2.Checked)
{
s += RadioButton2.Text;
} this.Label1.Text = "您选择的是:" + s;
}

最终效果:

上面就是RadioButton控件的使用方法。

RadioButton控件的更多相关文章

  1. wpf RadioButton控件的一个bug,onpropertychanged后会修改旧属性的值

    测试代码下载:http://files.cnblogs.com/djangochina/RadioButtonBug.zip 从上面列表选择不同的行,再设置下面不同的radiobutton看看结果 b ...

  2. wpf 自定义RadioButton控件样式

    实现的效果为: 我感觉来自定义RadioButton样式和定义button空间的样式差不多,只是类型不同而已. 接下来分析一下样式代码: <!--自定义单选按钮样式-->        & ...

  3. C# 中关于radiobutton控件的使用

    在一个Form窗口中定义了3个radiobutton,radioButton1.radioButton2和radioButton3,以及button1和button2(这里可以是其他控件) 为了实现单 ...

  4. form中动态生成Radiobutton控件

    public partial class GetLabelFields : Form { int tableCount; public GetLabelFields(AxMapControl axma ...

  5. asp.net RadioButton控件基础

    RadioButton按钮呢,必须要设置groupname属性的值才能将多个RadioButton按钮设置为单选按钮,当AutoPostBack="true"的时候,在change ...

  6. tkinter学习系列之(六)Radiobutton控件

    目录 目录 前言 (一)基本属性 (二)在Frame里布局: 目录 前言 Radiobutton单选框,在一组选框中,只能选中一个. (一)基本属性 (1)特有属性: value 按钮的值 varia ...

  7. Android RadioButton控件

    RadioButton   单选按钮 常用属性: text 文本 checked=“true” 默认选中 一组互斥的单选按钮要放在RadioGroup中.RadioGroup常用属性: orienta ...

  8. RadioButton控件选中、取消

    js: var flag = true; function chkRadio(id) { id.checked = flag; flag = !flag; } aspx.cs: this.rbtKey ...

  9. MVC RadioButton控件

    @Html.RadioButtonFor(m => m.IfValid, 1, new { @id = "radio1", @name = "rdolstState ...

随机推荐

  1. 从一个App跳转到另一个App

    在跳入App的info中配置Bundle identifier 在跳入App的info中配置URL Schemes 在另一个应用程序中按照上边的操作添加openURL并运行,就可以跳转了 调用open ...

  2. 使用python网络库下载

    下载1000次网页资源 1,普通循环方式下载1000次,非常慢 #!/usr/bin/python # -*- coding: utf-8 -*- import sys import os impor ...

  3. Swift:使用系统AVFoundation实现二维码扫描和生成

    系统提供的AVCaptureSession仅仅适用于iOS7.0以上的系统.之前的请用Zbar来替代 下载地址:http://download.csdn.net/detail/huobanbengku ...

  4. [置顶] JDK-Future 模式和实现

    最近的项目用到了多线程,发现java.util.concurrent.Future蛮好用的. 像平时,写多线程一般使用Thread/Runnable,直接扔给线程池执行就好了.但是遇到了一些需要获取线 ...

  5. 设计模式的C++实现 2.工厂模式

    工厂模式,实例化对象,用工厂方法取代new操作. 工厂模式基本与简单工厂模式差点儿相同,简单工厂中每次加入一个子类必须在工厂类中加入一个推断分支,这违背了开闭原则.而工厂模式的解决方法是将简单工厂中的 ...

  6. Scala函数---既存类型

    语法: Type ::= InfixType ExistentialClauses ExistentialClauses ::= „forSome‟ „{‟ ExistentialDcl {semi ...

  7. linux下内存调试工具——valgrind

    1.valgrind之memcheck  最常用的工具,用来检测程序中出现的内存问题,所有对内存的读写都会被检测到,一切对malloc()/free()/new/delete的调用都会被捕获.所以,它 ...

  8. Your Job Is Not to Write Code

    I am lucky enough to work with a small team of fantastic engineers who truly care about their custom ...

  9. Ext JS学习第十二天 Ext基础之操作dom ; get与fly 方法

    此文用来记录学习笔记 •嗯!首先,什么是DOM(Document Object Model) –W3C对DOM的定义:文档对象模型是一个平台,一个中立于语言的应用程序编程接口(API),允许程序访问并 ...

  10. 杭电ACM 素数判定

    素数判定 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...