【发布时间】:2014-09-17 15:09:34
【问题描述】:
在我网站的每个页面上,我都有一个包含不同语言文化的下拉列表,我正在尝试使用用户 cookie 中的当前字符串设置下拉列表的默认值。
如下所示,SelectList 的默认参数是Request.Cookies("_culture").Value),但在每次请求时,下拉菜单都会重置为索引 0。
@Using Html.BeginForm("GetCulture", "Base", FormMethod.Post, New With { _
.id = "CultureForm"
})
@Html.DropDownList("Culture", _
New SelectList(ViewBag.Culture, "Key", "Value", Request.Cookies("_culture").Value), _
New With { _
.class = "form-control lang-toggle hidden-xs", _
.onchange = "document.getElementById('CultureForm').submit();"
} _
)
End Using
谁能发现我做错了什么?有什么关于我应该知道的默认参数的吗?我可以确认 Request.Cookies("_culture").Value) 中的值也在 html select > option 值中。
【问题讨论】:
标签: asp.net asp.net-mvc vb.net cookies