zoukankan      html  css  js  c++  java
  • RadioButton控件

    前台代码:

    1 <div>
    2     <asp:RadioButton ID="RadioButton1" runat="server" GroupName ="sex" Text =""/>
    3     <asp:RadioButton ID="RadioButton2" runat="server" GroupName ="sex"  Text =""/>
    4     <asp:Button ID="Button1" runat="server" Text="Button" OnClick ="Button1_Click"/>
    5     <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    6 </div>

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

    后台代码:

     1 /// <summary>
     2 /// Button1按钮的单机事件
     3 /// </summary>
     4 /// <param name="sender"></param>
     5 /// <param name="e"></param>
     6 protected void Button1_Click(object sender, EventArgs e)
     7 {
     8     string s = string.Empty;
     9 
    10     if (RadioButton1.Checked)
    11     {
    12         s += RadioButton1.Text;
    13     }
    14     if (RadioButton2.Checked)
    15     {
    16         s += RadioButton2.Text;
    17     }
    18 
    19     this.Label1.Text = "您选择的是:" + s;
    20 }

    最终效果:

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

  • 相关阅读:
    单例模式
    分析GC日志
    JVM运行时参数
    JVM监控及诊断工具-GUI篇
    JVM监控及诊断工具-命令行篇
    性能监控与调优(概述篇)
    再谈类的加载器
    类的加载过程(类的生命周期)详解
    字节码指令集
    class文件结构
  • 原文地址:https://www.cnblogs.com/KTblog/p/4272995.html
Copyright © 2011-2022 走看看