查看
@using Hospital.Areas.Administration.Models
@model ConfirmationModel
@{
ViewBag.Title = "Index";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<section class="creating-doctor-section">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.LabelFor(m => m.SelectedDoctorId)
@Html.ListBoxFor(model => model.SelectedDoctorId, Model.Doctors, new { AutoPostBack = "True", onselectedindexchanged = "DoctorSelected", Id = "docs" })
@Html.ValidationMessageFor(x => x.SelectedDoctorId, "", new { @class = "text-danger" })
<div class="submit-button">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</section>
}
查看模型
namespace Hospital.Areas.Administration.Models
{
public class ConfirmationModel
{
[Required]
public string SelectedDoctorId { get; set; }
[Required]
public string SelectedPatientId { get; set; }
public IEnumerable<SelectListItem> Doctors { get; set; }
public IEnumerable<SelectListItem> Patients { get; set; }
}
}
请问我如何在我仅在ListBox中选择项目(不作为表单结果发送,而是在此之前)时实际显示值(例如,医生ID)。请给我您的解决方案! 谢谢!!!