所以我在 .NET 4.0 ASP.NET Web Pages Razor v2 解决方案中有这个小 cshtml 页面。
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "News For All Crew";
var db = Database.Open("ConnectionString");
var departmentsQry = "select Name from Info_Department_Names IPN order by Name";
}
<form method="post" action="">
<select id="selectStation" name="selectStation" onchange="this.form.submit();">
@foreach (var dept in db.Query(departmentsQry))
{
<option value="@dept.Name">@dept.Name</option>
}
</select>
</form>
当用户选择一个选项时,我希望它在回发后保持选择状态。我该怎么做呢?