我正在寻找为什么 Kendo Dropdownlist 框不保留我的价值并将其传递给请求。
我在 chtml 上有这个:
<form method="post" name="Lang">
Culture : @Culture
@(Html.Kendo().DropDownList()
.Name("cbLanguage")
.DataTextField("Name")
.DataValueField("Culture")
.BindTo(new List<Language>()
{
new Language() {Name = "Français (Canada)", Culture = "fr-CA"},
new Language() {Name = "English (Canada)", Culture = "en-CA"},
new Language() {Name = "English (United State)", Culture = "en-US"}
})
.Events(e => e
.Select("cbLanguage_select")
)
.Value(Culture)
)
<select name="lang" onchange="submitLang();">
<option></option>
<option value="en-US" @(Culture == "en-US" ? "selected=\"selected\"" : "")>English</option>
<option value="fr-CA" @(Culture == "fr-CA" ? "selected=\"selected\"" : "")>French</option>
</select>
</form>
<script>
function cbLanguage_select(e) {
$('form').submit();
};
function submitLang() {
$('form').submit();
}
</script>
之后,我将此代码放在_ViewStart 上。
if (!Request["lang"].IsEmpty())
{
Culture = UICulture = Request["lang"];
}
---- 或者这取决于我要测试的每个组合!!!!
if (!Request["cbLanguage"].IsEmpty())
{
Culture = UICulture = Request["cbLanguage"];
}
使用标准组合真的很好。但我从来没有收到带有剑道下拉列表的请求值。
我需要帮助找出原因!!!
谢谢!