zoukankan      html  css  js  c++  java
  • 主攻ASP.NET.3.5.MVC架构之重生:HtmlHelper(二)

    htmlhelper的优势就是有智能感知功能,不用helper后面的<%}%>也好去掉

    HtmlHelper

     

    SelectExtensions静态类

     

    DropDownList,ListBox 两个控件

     

    DropDownList

    DropDownList控件只能选择一个项

    <%=Html.BeginForm("DropDownList","Home")%>

    <fieldset>

    <legend>选着产品目录:</legend>

    <%=Html.DropDownList("CategoryID") %>

    <br /><br />

    <input type="submit" value="DropDownList" />

    </fieldset>

    <%Html.EndForm(); %>

    //

    // GET: /Admin/Test/

    [Authorize]

    public ActionResult Index()

    {

    CategoryRepository categoryrepository = new CategoryRepository();

    var categorylist = categoryrepository.GetModelListByState(1);

    ViewData["CategoryID"] = SelectListExtension.ToSelectList(categorylist, d => d.CategoryName, d => d.CategoryID.ToString(), "全部");

    return View();

    }

     

     

     

     

    ListBox

    ListBox控件可以是多个选项,因此multiple属性被设置为” multiple”

     

     

    <%=Html.BeginForm("DropDownList","Home")%>

    <fieldset>

    <legend>选着产品目录:</legend>

    <%=Html.ListBox("CategoryID")%>

    <br /><br />

    <input type="submit" value="DropDownList" />

    </fieldset>

    <%Html.EndForm(); %>

     

     

    TestAreaExtensions静态类

     

    TestArea

     

    <%=Html.TextArea("textArea",new{rows=5,cols=10}) %>

     

     

    <%=Html.TextArea("textArea","data") %>

     

    ValidationExtensions静态类

    Validation验证控件

    <%using(Html.BeginForm()){%>

    <fieldset>

    <legend>Fields</legend>

    <p>

    <label for="ProductName">ProductName</label>

    <%=Html.TextBox("ProductName") %>

    <%=Html.ValidationMessage("ProductName","*") %>

    </p>

    </fieldset>

    <%} %>

     

     

     

  • 相关阅读:
    Java以指定格式输入数字
    毕向东JAVA视频讲解(第六课)
    毕向东JAVA视频讲解(四五课)
    毕向东JAVA视频讲解笔记(前三课)
    C++ Primer笔记整理
    map的详细用法
    opencv中的矩阵操作
    Matlab程序 转C++/Opencv基于Mat 不可不知的17个函数
    目标检测的图像特征提取之(三)Haar特征
    目标检测的图像特征提取之(二)LBP特征
  • 原文地址:https://www.cnblogs.com/cube/p/2515967.html
Copyright © 2011-2022 走看看