Control Language Inherits System Web Mvc ViewUserControl Html BeginFor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<% Html.BeginForm(); %>
<%{ %>
<%
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem { Text = "Please select country", Value = "", Selected = true });
items.Add(new SelectListItem { Text = "China", Value = "1" });
items.Add(new SelectListItem { Text = "Russia", Value = "2" });
items.Add(new SelectListItem { Text = "Ukraine", Value = "3" });
%>
<%= Html.DropDownList(
"ddlCountry",
(IEnumerable<SelectListItem>)items,
new { id = "ddlCountry", name = "ddlCountry", style= "width:204px"
})%>
<%} %>