美文网首页
MVC---模板Help Methods

MVC---模板Help Methods

作者: Sombod_Y | 来源:发表于2017-01-02 21:57 被阅读0次

    <strong>一. 使用模板Help Methods</strong>

    @using (Html.BeginRouteForm("FormRoute", new { }, FormMethod.Post, new { @class = "personClass", data_formType = "person" }))
    {
        <div class="dataElem">
            <label>PersonId</label>
            @Html.Editor("PersonId")
        </div>
        <div class="dataElem">
            <label>First Name</label>
            @Html.Editor("FirstName")
        </div>
        <div class="dataElem">
            <label>Last Name</label>
            @Html.EditorFor(m => m.LastName)
        </div>
        <div class="dataElem">
            <label>Role</label>
            @Html.EditorFor(m => m.Role)
        </div>
        <div class="dataElem">
            <label>Birth Date</label>
            @Html.EditorFor(m => m.BirthDate)
        </div>
        <input type="submit" value="Submit" />
    }
    

    <strong>1.1 生成标签和显示元素</strong>

    <div class="dataElem">
        @Html.Label("PersonId")
        @Html.Display("PersonId")
    </div>
    <div class="dataElem">
        @Html.Label("FirstName")
        @Html.Display("FirstName")
    </div>
    <div class="dataElem">
        @Html.LabelFor(m => m.LastName)
        @Html.DisplayFor(m => m.LastName)
    </div>
    <div class="dataElem">
        @Html.LabelFor(m => m.Role)
        @Html.DisplayFor(m => m.Role)
    </div>
    <div class="dataElem">
        @Html.LabelFor(m => m.BirthDate)
        @Html.DisplayFor(m => m.BirthDate)
    </div>
    

    相关文章

      网友评论

          本文标题:MVC---模板Help Methods

          本文链接:https://www.haomeiwen.com/subject/zeawvttx.html