我完全是MVC的新手。我想創建一個Viewbag來包含控件的選定索引。我可以在我的.ascx文件中設置它嗎?或者什麼是捕獲這些信息的最佳方式?ASP.Net MVC3 Viewbag - 設置爲dropdownbox的選定索引
<select id="accounttype" style="float: left;" autocomplete="off">
<%
if (Request.Url.AbsolutePath.ToUpper().StartsWith("/COMMERCIAL")) //Commercial
{
%>
<option value="C" selected="selected">eManager+</option>
<option value="C">Retirement Plans</option>
<option value="C">Brokerage Accounts</option>
<%
}
else if (Request.Url.AbsolutePath.ToUpper().StartsWith("/BUSINESS")) //Business
{
%>
<option value="B" selected="selected">eManager+</option>
<option value="B">Business Credit Card</option>
<option value="B">Retirement Plans</option>
<option value="B">Brokerage Accounts</option>
<%
}
else //Personal, root or other
{
%>
<option value="P" selected="selected">Online Banking</option>
<option value="P">Health Savings Account</option>
<option value="P">Paychek Plus!®</option>
<option value="P">Gift Cards</option>
<option value="P">Business Tax Manager</option>
<option value="P">Business Card Manager</option>
<option value="P">Business Credit Card</option>
<%
}
%>
</select>