我想使用jquery在我的dropdownlist中選擇一個項目,但它將清空我的ActionResult,從而導致以下錯誤:「付款方式字段是必需的。放置一個警報,看看它是否得到了下拉列表的ID,它是正確的問題是我如何將該ID發送到我的控制器?選擇選項包含驗證模型時無法正常工作MVC
JQUERY:
$("#ddlFormaPagamento").find("option:contains('Cartão de Crédito')").each(function() {
if ($(this).text() == 'Cartão de Crédito') {
$(this).prop("selected", "selected");
}
});
我的領域:
@Html.DropDownListFor(model => model.intFormaPagamentoId, ViewBag.FormaPagamentoList as IEnumerable<SelectListItem>, "",
new { @Id = "ddlFormaPagamento", @style = "width:404px;" })
你能否詳細說明您的問題? 「我怎麼把這個ID發送給我的控制器? – PSL