Control Language Inherits System Web Mvc ViewUserControl select id ddl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<select id="ddlCountry" name="ddlCountry" style="width: 202px">
<option value="">Please select country</option>
<option value="1">China</option>
<option value="2">Russia</option>
<option value="3">Ukraine</option>
</select>
<%--<% 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"
})%>
<%} %>--%>