zoukankan      html  css  js  c++  java
  • MVC进阶学习HtmlHelper控件解析(二)

    1.InputExtensions类
          InputExtensions类主要有5种类型的扩展方法,分别用于CheckBox控件,Hidden控件,Pass控件,RadionButton控件,TextBox控件

    2.CheckBox控件
          有如下重载方法:
          CheckBox(string name);
          CheckBox(string name,bool isChecked);
          CheckBox(string name,book isChecked,object htmlAttributes);
          CheckBox(string name,object htmlAttributes);
          CheckBox(string name,IDictionary<string ,object> htmlAttributes);
          CheckBox(string name,book isChecked,IDictionary<string ,object> htmlAttributes);
          例子:
          页面代码 
    Code
          生成页面之后的html代码如下:
          
    Code

          对比上面的代码我们发现,<%=Html.CheckBox()%> 除了生产CheckBox标签之外还生成了一个隐藏的表单域,他和Checkbox具有相同的name。
          
          处理表单的aciton
    Code
          通过表单集合FormCollection的索引或键,可以获取复选框的状态字符串,如果选中则得到值为"true,false",
          如果没有选中得到的值为"false",这里得到两个值是因为Checkbox还有一个对应的隐藏控件

    3.RadionButton控件
          RadionButton(string name,object value);
          RadionButton(string name,object value,object htmlAttributes);
          RadionButton(string name,object value,IDictionary<string,object> htmlAttributes);
          RadionButton(string name,object value,bool isChecked);
          RadionButton(string name,object value,bool isChecked,object htmlAttributes);
          RadionButton(string name,object value,bool isChecked,IDictionary<string,object> htmlAttributes);
          这里不同Checkbox,不会生成隐藏的表单域,action中得到的值也不是True false,而是设置的值,这里不再详细讲解
    Code

    3.Hidden控件
          Hidden(string name);
          Hidden(string name,object value);
          Hidden(string name,object value,object htmlAttrbutes);
          Hidden(string name,object value,IDictionary<string ,object> htmlAttributes);
          该方法生产隐藏表单域
          
    4.PassWord控件
          Password(string name);
          Password(string name,object value);
          Password(string name,object value,object htmlAttrbutes);
          Password(string name,object value,IDictionary<string ,object> htmlAttributes);
          该方法生成PassWord输入框

    5.TextBox控件
          TextBox(string name);
          TextBox(string name,object value);
          TextBox(string name,object value,object htmlAttrbutes);
          TextBox(string name,object value,IDictionary<string ,object> htmlAttributes);
          该方法生成普通文本输入框
  • 相关阅读:
    linux redis安装 5.0.2
    Linux nginx安装步骤 centos7
    fastjson JSONObject.toJSONString 出现 $ref: "$."的解决办法(重复引用)
    docker redis安装及配置(外网访问 关闭安全限制 设置密码)
    JDK dump
    mysql8 修改root密码
    docker系列详解<二>之常用命令
    获取地理位置
    js调用摄像头
    点击时扩散效果
  • 原文地址:https://www.cnblogs.com/qingyuan/p/1580316.html
Copyright © 2011-2022 走看看