我有一个MVC应用程序,我正在从MVC1重写为MVC4。在搜索表单上,前两个@ Html.TextBox()元素不可单击。您可以选中它们,但不能单击。如果你在它们上方放置了更多的文本框元素,它们就会变成可点击的,如果你改变了顺序,那么前两个就会被破坏。
这是我的代码:
@{
ViewBag.Title = "Search";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Search</h2>
@if (ViewData["ErrorMessage"] != null)
{
@Html.ValidationSummary(ViewData["ErrorMessage"].ToString(), new { @style = "color: #FF0000" })
}
<fieldset>
<legend>Criteria</legend>
@using (@Html.BeginForm())
{
<label>Social Security Number:</label>
@Html.TextBox("SSN", null, new { @class = "input-box", style = "width:100%" })
@Html.ValidationMessage("SSN", "*", new { @style = "color: #FF0000" })
<label>Date of Birth:</label>
@Html.TextBox("DOB", null, new { @class = "input-box", style = "width:100%" })
@Html.ValidationMessage("DOB", "*", new { @style = "color: #FF0000" })
<label>First Name:</label>
@Html.TextBox("FirstName", null, new { @class = "input-box", style = "width:100%" })
@Html.ValidationMessage("FirstName", "*", new { @style = "color: #FF0000" })
<label>Last Name:</label>
@Html.TextBox("LastName", null, new { @class = "input-box", style = "width:100%" })
@Html.ValidationMessage("LastName", "*", new { @style = "color: #FF0000" })
<p style="text-align:center;">
<input class="button" type="submit" value="Search" style="align-items:center"/>
</p>
}
</fieldset>
<p>@Html.ActionLink("Create New", "Create")</p>
答案 0 :(得分:0)
问题是布局页面中有未闭合的div元素。重写布局后,应用程序运行正常。