gpt4 book ai didi

css - 表单的 Bootstrap 显示

转载 作者:行者123 更新时间:2023-11-28 11:59:54 25 4
gpt4 key购买 nike

这对我来说没有意义。我正在尝试在我的 MVC5 元素中显示一个带有 4 个输入字段的表单。当我不使用 @using (HTML.BeginForm(...){..}

@using (Html.BeginForm("Create", "HR", FormMethod.Post)) {

我的显示器看起来很完美 enter image description here

但是一旦我输入 @using (HTML.BeginForm(..) 语句,显示如下: enter image description here

我的 html 助手哪里出错了?

这是我正在使用的一些示例 html 辅助方法..

<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading"><h4>Create New Employee</h4></div>
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2">First Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", placeholder = "Enter First Name" })
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Middle Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.MiddleName, new { @class = "form-control", placeholder = "Enter Middle Name" })
</div>
</div>
</form>
</div>
</div>

最佳答案

看起来您在使用 @Html.BeginForm 时丢失了类属性。像这样添加回去:

<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading"><h4>Create New Employee</h4></div>
<div class="panel-body">
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { @class="form-horizontal" }))
{
<div class="form-group">
<label class="control-label col-sm-2">First Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", placeholder = "Enter First Name" })
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Middle Name</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.MiddleName, new { @class = "form-control", placeholder = "Enter Middle Name" })
</div>
</div>
}
</div>
</div>

关于css - 表单的 Bootstrap 显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47561373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com