我试图了解如何将下拉选择的值提交回MVC控制器。我有一个ShielUI DIV,然后是原始的MVC Using语句。如何将提交语句更改为$(“#mainForm”)。submit());或任何其他方法?
谢谢你的帮助。
<div>
<div class="outerDiv">
<div class="innerDiv">
<label for="comboBoxTech">Select from list</label>
<br />
@(Html.ShieldComboBox()
.Width(200)
.Name("comboBoxTech")
.AutoComplete(ab => ab.Enabled(true))
.DataSource(dsb => dsb.Data(dropdown.ToArray())))
<br />
<br />
@(Html.ShieldButton()
.Name("submit")
.Html("Submit")
.Events(e => e.Click(@<text>
function() {
$("#mainForm").submit());
}
</text>)))
</div>
<div class="imageDiv"></div>
</div>
</div>
@using (Html.BeginForm("ValidateJN", "Home", FormMethod.Get))
{
<p>
@Html.DropDownList("JobsList", string.Empty) and <input type="submit" value="Submit">
</p>
}
答案 0 :(得分:1)
使用$ .post(与$ .Ajax相同。)运行良好。
<div>
<div class="outerDiv">
<div class="innerDiv">
<label for="comboBoxTech">Select from list</label>
<br />
@(Html.ShieldComboBox()
.Width(200)
.Name("comboBoxTech")
.AutoComplete(ab => ab.Enabled(true))
.DataSource(dsb => dsb.Data(dropdown.ToArray())))
<br />
<br />
@(Html.ShieldButton()
.Name("submit")
.Html("Submit")
.Events(e => e.Click(@<text>
function(e) {
$.post("Home/ValidateJN", { comboBoxTech : $("#comboBoxTech").val()});
}
</text>)))
</div>
<div class="imageDiv"></div>
</div>
</div>