我正在嘗試將值從 MVC 表單傳遞給 JavaScript。我正在使用引導程序來隱藏和顯示字段。當我刪除表單上的引導程序隱藏和顯示功能時,我將在消息框中獲得值,但是當啟用隱藏/顯示時,我無法獲得如下圖所示的值。誰能告訴我哪里出錯了HTML @using (Html.BeginForm("SearchPatient","HOME", FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.AntiForgeryToken() <div class="form-horizontal"> <div class="form-group"> @Html.Label("Search Criteria", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownListFor(model => model.SearchCriteria, new List<SelectListItem> { new SelectListItem { Value = "" , Text = "Select Search Criteria" }, new SelectListItem { Value = "1" , Text = "Patient Id" }, }, new { @class = "form-control selectchosen" }) </div> </div> <div class="form-group" id="PatientId" style="display:none"> <div class="form-group"> @Html.LabelFor(model => model.PatientId, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.PatientId, new { htmlAttributes = new { @class = "form-control " } }) </div> </div> </div> <div class="form-group" id="AllShow" style="display:none"> <div class="form-group"> <div class="col-lg-offset-2"> <input type="button" value="Search" class="btn btn-success" id="btnSubmit" onclick="Enablecontrols();" /> </div> </div> </div> </div> }
使用引導程序隱藏和顯示字段時,MVC 表單值未傳遞給 JavaScript
一只甜甜圈
2022-01-07 09:51:10