【发布时间】:2023-04-10 11:51:01
【问题描述】:
我需要将选定的下拉项文本而不是值发送到控制器。 这是查看代码
@using (Html.BeginForm("Index", "Home"))
{
<div class="container">
<div class="form-group">
@if (ViewBag.CountryList != null)
{
@Html.DropDownListFor(model => model.CountryId, ViewBag.CountryList as SelectList, "choose country", new { @class = "form-control" })
}
</div>
<button type="submit">Send</button>
</div>
}
在控制器中,我尝试访问提交表单的请求上下文,但它返回的是值,而不是所选项目的文本。请帮助将所选下拉项的文本检索到控制器。
【问题讨论】:
标签: c# .net asp.net-mvc model-view-controller