zoukankan      html  css  js  c++  java
  • [记录]ASP.NET MVC 2.0 如何使用Html.RadioButtonFor?

    MVC 2.0里支持强类型实体绑定,可以直接使用如

    <%: Html.TextBoxFor(model => model.Description, new { @class="text"})%>
    

     来自动将实体绑定到表单里,但我不知道如何使用 Html.RadioButtonFor 来生成 RadioButton ? 在使用 Html.RadioButtonFor 必须至少2个参数,另一个是指一个object,我绑定的字段是一个bool型的,如何能自动生成相关的RadioButton 呢?

    开始时一直觉得一句话就可以完成,弄了半天也没成功,后来想起了其实调用一次 Html.RadioButtonFor 就只生成一个 RadioButton,那又怎么可能一句就生成2个button呢?呵,傻了吧,唉,其实只要分别调用2次就可以了啊,然后再加上个 if 判断一下当前值即可,以下是实现的代码:

  • 相关阅读:
    vue ssr
    webpack-dev-server proxy代理
    PHP连数据库生成数据字典
    redis.rpm 安装
    centos 6.5安装NodeJS
    Jenkins + git + maven 安装
    最新版本GIT安装
    身份证校验
    快递100物流公司列表
    redis 安装
  • 原文地址:https://www.cnblogs.com/Raywang80s/p/3620196.html
Copyright © 2011-2022 走看看