表单元素:

文本类:

text

password

textarea

hidden

text,password,textarea实现控件:textbox   textmode属性选择password或multiline或singleline

textmode的multiline对应textarea

textmode的singleline对应text

可以对应text设置最大长度maxlength,而对于textarea无此项

隐藏域hidden对应控件为hiddenfield,用value可以对其赋值,但无法看到

按钮类:

button

submit

reset

image

button无对应控件

submit对应控件为button

reset无对应控件

image对应控件imagebutton

linkbutton超链接模样的按钮

其他的简单控件:

label:编译会编译成span类型

重要属性:text--文本

    enabled--是否可用

    visible--是否可见

literal:编译会直接编译成空文本

重要属性:text  

  

复合控件:

radiobutton和radiobuttonlist:

1、绑定数据:

   RadioButtonList1.DataSource = slist;
        RadioButtonList1.DataTextField = "Name";
        RadioButtonList1.DataValueField = "Code";
        RadioButtonList1.DataBind(); - 很重要!!!

2、设置选中项:

  按照索引选中:
  RadioButtonList1.SelectedIndex = slist.Count - 1;
  
  按照value值选中:
  RadioButtonList1.SelectedValue = "002";
 
  按照Text选中:
     foreach (ListItem li in RadioButtonList1.Items)
        {
            if (li.Text == "周村")
            {
                li.Selected = true;
            }
        }

3、取出数据:

取出value值
   Label1.Text = RadioButtonList1.SelectedValue;

取出Text值
   Label1.Text = RadioButtonList1.SelectedItem.Text;

checkbox和checkboxlist:

1、绑定数据:

   checkboxlist1.DataSource = slist;
        checkboxlist1.DataTextField = "Name";
        checkboxlist1.DataValueField = "Code";
        checkboxlist1.DataBind();

2、设置选中项:

按照索引选中:
  checkboxlist1.SelectedIndex = slist.Count - 1;
  
  按照value值选中:
  checkboxlist1.SelectedValue = "002";
 
  按照Text选中:
     foreach (ListItem li in checkboxlist1.Items)
        {
            if (li.Text == "周村")
            {
                li.Selected = true;
            }

    if(li.text=="张店")

    {

    li.selected=true;

    }
        }

3、取出数据:

取出value值    Label1.Text = checkboxlist1.SelectedValue;

取出一个Text值    Label1.Text = checkboxlist1.SelectedItem.Text;

取出一堆值:

foreach (ListItem li in CheckBoxList1.Items)
  {
     if (li.Selected == true)
     {
      Label1.Text += li.Text + ",";
     }
  }

dropdownlist与前面的用法相同

webform简单控件的更多相关文章

  1. WebForm简单控件,复合控件

    简单控件: 1.Label 会被编译成span标签 属性: Text:文本内容 CssClass:CSS样式 Enlabled:是否可用 Visible:是否可见 __________________ ...

  2. WebForm 简单控件、复合控件

    简单控件: Label:被编译成span 样式表里设置lable的高度:  display:inline-block; Text  --文本 ForeColor  --字体颜色 Visible  -- ...

  3. webform 简单控件

    html中12个表单元素添加runat="server"后称为控件 Lable 编译之后是 <span></span> 属性:CssClass  编译成 c ...

  4. Webform(简单控件、复合控件)

    一.简单控件: 1.label控件 <asp:Label ID="Label1" runat="server" Text="账 号:" ...

  5. WebForm 【简单控件】【表单元素】

    一.HTML 表单元素复习 (1)文本类 文本框:<input type="text" name="" id="" value=&qu ...

  6. 【2017-05-18】WebForm的Repeater控件和一些简单控件

    一.Repeater控件 1. <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <% ...

  7. 【2017-05-18】WebForm的Repeater控件及简单控件

    <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <%# Eval("属性名 ...

  8. 2013 duilib入门简明教程 -- 简单控件介绍 (12)

        前面的教程应该让大家对duilib的整体有所映像了,下面就来介绍下duilib具体控件的使用.     由于官方没有提供默认的控件样式,所以我就尽量使用win7或者XP自带的按钮样式了,虽然界 ...

  9. WebForm 常用控件

    一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...

随机推荐

  1. Yii源码阅读笔记(二十九)

    动态模型DynamicModel类,用于实现模型内数据验证: namespace yii\base; use yii\validators\Validator; /** * DynamicModel ...

  2. C#整数三种强制类型转换int、Convert.ToInt32()、int.Parse()的区别

    1.int适合简单数据类型之间的转换,C#的默认整型是int32(不支持bool型); 2.int.Parse(string sParameter)是个构造函数,参数类型只支持string类型; 3. ...

  3. 使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析

    使用所见即所得文本编辑器编辑文本存入数据库后通过ajax获取服务器json_encode的数据到前台,文本内容上边的html标签不解析 因为我在前台使用了jquery的text()方法,而不是html ...

  4. jq验证码换一换

    <!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-e ...

  5. Apache Benchmark测试工具

    ab命令-- ab -c 数字(连接数) -t 数字(连接时间) http://网站:端口/路径 ab -n 数字(点击数) -c 数字(连接数) -k(同时点击) http://网站:端口/路径

  6. URLRedirector 解决网页上无法访问 google CDN 的问题(fonts、ajax、themes、apis等)

    URLRedirector 解决网页上无法访问 google CDN 的问题(fonts.ajax.themes.apis等) 由于某些原因,在访问国外的网站时有时候会特别慢,像 stackoverf ...

  7. 图像的 SNR 和 PSNR 的计算

    PSNR 的公式很容易搜到. http://www.360doc.com/content/12/0605/21/4129998_216244993.shtml http://blog.sina.com ...

  8. 忘记Linux root用户的密码怎么办?

    以前忘记windows密码的时候,要么用工具清除,要么重装系统.假如你忘记了linux系统的root密码,怎么办呢?是像windows一样用工具破解还是重装系统呢?哈哈,都不用.这方法很简单,现在做一 ...

  9. 关于Thread.IsBackground属性的理解(转载)

    C#中,Thread类有一个IsBackground 的属性.MSDN上对它的解释是:获取或设置一个值,该值指示某个线程是否为后台线程.个人感觉这样的解释等于没有解释. .Net中的线程,可以分为后台 ...

  10. echarts入门基础,画柱型图

    注意:一定要自己引入echarts库 <!DOCTYPE html> <html> <head> <meta charset="UTF-8" ...