情况:我form
需要从我的页面/视图中读取一些信息,以将其存储在控制器中使用,该控制器在点击form
. 问题是我同时拥有 adropdownlist
和 atextbox
我试图用它们来表示form
. 有人知道我如何有效form
地选择正确的控件来读取该属性吗?
表格的型号:
public class EventListForm
{
public int Id { get; set; }
[StringLength(50)]
public virtual string Location { get; set; }
[StringLength(100)]
public virtual string AccessPoints { get; set; }
}
表单所在的视图包括将从中读取的控件:
<% using (Html.BeginForm("Save", "Event", new { }, FormMethod.Post, new { id = "selectEditEventForm" })) { %>
<table class="data-table">
<tr>
<td><label for="Id" class="xl">Event:</label></td>
<td><%=Html.DropDownListFor(x => x.Id, Model.Events.OrderByDescending(x => x.Value.AsDecimal()), new { @class = "info1" })%></td>
</tr>
<tr>
<td><label for="Location" class="xl">Location:</label></td>
<td><%=Html.TextBoxFor(x => x.Location, new { @class = "location info2 xl", maxlength = "250" })%></td>
</tr>
<tr>
<td><label for ="AccessPoint" class="xl">Access Point:</label></td>
<td><%= Html.DropDownListFor(x => x.Id, Model.AccessPoints.OrderByDescending(x => x.Value.AsDecimal()), new { @id = "selectAccessPoint", @class = "info2"})%></td>
</tr>
<tr>
<td><label for ="AccessPoint" class="xl" >Or Add New:</label></td>
<td><%= Html.TextBoxFor(x => x.AccessPoints, new { @id = "newAccessPoint", @class = "location info2", maxlength = "250" }) %></td>
</tr>
我已经包含了 JS 来禁用textbox
ifdropdownlist
使用和禁用dropdownlist
if thetextbox
使用。显然,我可以form
从textbox
ifdropdownlist
不在页面上读取,但我无法从if不在页面上form
读取。可以指出我正确的方向吗?我应该只包括另一个属性吗?dropdownlist
textbox
form