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

    简单控件:

    1、Label

      会被编译成span标签

      属性:

      Text:文本内容

      CssClass:CSS样式

    <asp:Label ID="Label1" runat="server" Text="1234" CssClass="aaa"></asp:Label>

      Enlabled:是否可用

      Visible:是否可见

    2、Literal

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

      属性:

      Text:内容

    <asp:Literal ID="Literal1" runat="server" Text="2016-12-29"></asp:Literal>

    <asp:Literal ID="Literal1" runat="server" Text="<script>alert('2016年12月29日')</script>"></asp:Literal>

    alert:弹出

    3、TextBox

      文本框

      属性:

      TextMode - text模式

      1、默认 SingleLine - 单行文本框,编译后为 type="text"

      2、Password - 密码框,编译后为 type="password"

      3、MultiLine - 文字域,编译后为 <textarea></textarea>

      在设计界面中 textmode 属性有多个,只用前三个

      maxlength:最大长度,在文本域 <textarea></textarea> 中不起作用

      readonly:只读属性

    4、HiddenField

      隐藏域

    5、Button

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

         imagebutton - image 提交图片

         linkbutton - 超链接模样的按钮,仅控件如此

         button、reset - 没有控件对应

    button属性:

       OnClientClick - 在客户端OnClick上执行的客户端脚本

    复合控件:

    1、RadioButton 和 RadioButtonList

      单选按钮

         大多情况下使用后者

    前者:

    <asp:RadioButton ID="RadioButton1" runat="server" Text="" />
    <asp:RadioButton ID="RadioButton2" runat="server" Text="" />

    属性:

      GroupName - 分组,用于选择

    <asp:RadioButton ID="RadioButton1" runat="server" Text="" GroupName="sex" />
    <asp:RadioButton ID="RadioButton2" runat="server" Text="" GroupName="sex" />

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

  • 相关阅读:
    PHP操作MongoDB GridFS 存储文件
    使用PHP来开发MongoDB并在shell查看数据
    MongoDB之PHP驱动安装配置
    MongoDB之GridFS存储文件
    laya 下以光标为中心缩放对象
    canvas 鼠标位置缩放图形
    gunicorn 基础配置使用
    keras 学习笔记:从头开始构建网络处理 mnist
    web 上读取图片,并转化为指定格式
    oracle 正则表达的使用
  • 原文地址:https://www.cnblogs.com/jiuban2391/p/6237390.html
Copyright © 2011-2022 走看看