嗨,我正在构建应用程序来显示报告,我有一组设置,我希望用户选择,并且在他选择预览更新时。它是强类型视图:
@model MRS.UI.Models.SettingsModel
@using (Html.BeginForm("Settings", "Report", FormMethod.Post))
{
<div class="white-box edit-box">
@Html.DropDownListFor(m => m.range, new SelectList(new List<Object>{new { value = 0, text = "12 hours"},
new { value = 1, text = "24 hours"},
new { value = 2, text = "4 days"},
new { value = 3, text = "8 days"},
new { value = 4, text = "16 days"},
new { value = 5, text = "month"},
new { value = 6, text = "quarter"},
new { value = 7, text = "year"}
},
"value",
"text",
Model.range
), new { @class = "select_change" }
)
@Html.TextBoxFor(m => m.title)
@Html.RadioButtonFor(m => m.layout, 1) <p>Layout 1</p><br />
@Html.RadioButtonFor(m => m.layout, 2) <p>Layout 2</p><br />
@Html.RadioButtonFor(m => m.layout, 3) <p>Layout 3</p><br />
@Html.RadioButtonFor(m => m.layout, 4) <p>Layout 4</p><br />
<input class="blueButton" type="submit" value="Complete Report"/>
</div>
}
<script>
$('.select_change').change(function () { alert(@Model.range); })
</script>
在我按下“完成报告”后,数据正在保存,然后我可以在不同的视图上使用它,但是我如何在同一个视图上使用它,而被选中。我尝试使用 JavaScript 以警报消息的形式显示范围值,但它显示未更新的值。
如何在 @Html.DropDownListFor 中使用选定的值?
非常感谢您的帮助