我想在 dropDown 更改时打印一些文本。然后在提交时将标签文本保存到数据库。目前在标签上打印值工作正常,但在提交时我没有收到标签文本。
$(document).ready(function () {
$('#StockID').change(function () {
// ajax call
function successFunc(data, status) {
$("#lblTotal").text("Stock Value: " + data.Result);
}
}
})
});
<div class="editor-field">
<%: Html.DropDownListFor(x => x.StockID, new SelectList(Model.lstStock, "StockID", "Description"), "-- Please Select a Stock --")%>
<%: Html.ValidationMessageFor(model => model.StockID)%>
</div>
<div id="clslbl">
<br />
<label id="lblTotal"></label>
</div>
控制器:
if (ModelState.IsValid)
{// TODO: Add insert logic here
string a = Request.Form["lblTotal"]; // here i'm not getting the label text
return RedirectToAction("Index");
}