我想从两个 DropDowns 访问 Selected Keys,然后以 Keys 作为参数调用控制器操作。
在我的 MVC 视图中,我有以下代码:
@model Test.Models.LoginViewModel
<p>
Database @Html.DropDownListFor(x => x.SelectedDatabase, Model.DatabaseList, "-- Select an Item --", new {@id="databaseDD", @name="databaseDD"})
</p>
<p>
Language @Html.DropDownListFor(x => x.SelectedLanguage, Model.LanguageList, "-- Select an Item --", new {@id="languageDD", @name="languageDD"})
</p>
<p>
@using (Html.BeginForm("LoginToService", "Home", new { databaseKey = Model.SelectedDatabase, languageKey = Model.SelectedLanguage }, FormMethod.Post, new { target = "_self" }))
{
<input id="login" type="submit" name="login" value="Login" />
}
</p>
问题是,当下拉选择更改时,未设置属性 Model.SelectedDatabase 和 Model.SelectedLanguage。如何访问 Selected Keys 并将它们用作参数?