• 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:设置是否可以多选

      

  • 相关阅读:
    关于Form窗体的StartPosition 属性如何设置的问题
    Oracle的JDBC Url的几种方式
    spring boot不同环境读取不同配置
    spring的启动过程就是创建ioc容器的过程
    spring容器启动过程理解
    spring mvc流程理解
    @responsebody注解的作用就是让viewresolver不起作用,不返回视图名称而是直接返回的return object
    @Controller和@RestController的区别?
    项目包名和分层都是按照代码来分的,不是按照业务。包名是:组织名称+代码分层
    WebMvcConfigurer
  • 原文地址:https://www.cnblogs.com/wt627939556/p/6233146.html
Copyright © 2020-2023  润新知