如何在MVC中更改TextBoxFor中的名称?

时间:2015-09-01 20:51:39

标签: asp.net-mvc

我想在页面上动态添加新的部分表单。我用了这段代码:

 Guid index = Guid.NewGuid();

<input type="hidden" name="People.index" value="@index" />
<hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.surname, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.TextBoxFor(model => model.surname, new { name = "Author[index].surname", htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.surname, "", new { @class = "text-danger" })
        </div>
    </div>

但是在页面加载后的源代码中我看到了:

 <div class="form-group">
        <label class="control-label col-md-2" for="surname">Фамилия</label>
        <div class="col-md-10">
            <input htmlAttributes="{ class = form-control }" id="surname" name="surname" type="text" value="" />
            <span class="field-validation-valid text-danger" data-valmsg-for="surname" data-valmsg-replace="true"></span>
        </div>
    </div>

我如何在名字字段中启用Guid?如何更改TextBoxFor中的字段?

0 个答案:

没有答案