WebForm简单控件,复合控件

简单控件:

1、Label

  会被编译成span标签

  属性:

  Text:文本内容

  CssClass:CSS样式

  Enlabled:是否可用

  Visible:是否可见

___________________________________________________________________________________________________________________________

2、Literal

  空的,C#会把里面的Text内容直接作为网页代码传过去,比如Text里面写上<input type="button" />会直接在网页中插入一个按钮

  属性:

  Text:内容

___________________________________________________________________________________________________________________________

3、TextBox

  文本框

  属性:

  TextMode:SingleLine(普通Text单行文本框)PassWord(密码框)MultiLine(文本域)

___________________________________________________________________________________________________________________________

4、HiddenField

  隐藏域

5、Button

  提交按钮(控件中没有对应的普通按钮和重置按钮)

6、ImageButton

  图片按钮

7、LinkButton

  超链接模样的按钮

复合控件:

1、RadioButton 和 RadioButtonList

  单选按钮

  大多情况下使用后者

  绑定数据:    

    RadioButtonList1.DataSource = 泛型集合;

    RadioButtonList1.DataTextField = "Name";

    RadioButtonList1.DataValueField = "Code";

    RadioButtonList1.DataBind(); - 必须要有

  设置选中项:    

    按照索引选中:

    RadioButtonList1.SelectedIndex = slist.Count - 1;

    按照value值选中:

    RadioButtonList1.SelectedValue = "002";

    按照Text选中:

    foreach (ListItem li in RadioButtonList1.Items)

    {

      if (li.Text == "周村")

      {

      li.Selected = true;

      }

    }

  取出数据:

    取出value值

    Label1.Text = RadioButtonList1.SelectedValue;

    取出Text值

    Label1.Text = RadioButtonList1.SelectedItem.Text;

  属性:

    RepeatDirection:横向或竖向排列

    RepeatLayout:编译成表格、流式或者有序无序列表的样式 

___________________________________________________________________________________________________________________________

2、CheckBox 和 CheckBoxList

  复选按钮

  绑定数据源与设置单个选择项同上,如果要设置多个选择项,则需要遍历

    foreach (ListItem li in CheckBoxList1.Items)

    {

      if (li.Selected == true)

      {

      Label1.Text += li.Text + ",";

      }

    }

___________________________________________________________________________________________________________________________

3、DropDownList

  下拉菜单

  与单选按钮列表类似

4、ListBox

  多选框

  与ChekckBoxList类似

  属性:

    SelectionMode:设置是否可以多选

转载于:https://www.cnblogs.com/wuxiaochao/p/6242195.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值