0
我是新的MVC和我堅持這個問題我有一個ViewUserControl與一個小的聯繫表單,我已經創建了這個ContactForm的模式。ASP.NET MVC DropDownList裏面ViewUserControl
[Required(ErrorMessage = "Type your Name"), DataType(DataType.Text)]
[DisplayName("Name")]
public string NameProperty { get; set; }
[Required(ErrorMessage = "Type your Mobile"), DataType(DataType.Text)]
[DisplayName("Mobile")]
public string MobileProperty { get; set; }
[Required(ErrorMessage = "Type your City"), DataType(DataType.Text)]
[DisplayName("City")]
public string CityProperty { get; set; }
[Required(ErrorMessage = "Select Product"), DataType(DataType.Text)]
[DisplayName("Product")]
public IEnumerable<SelectListItem> ProductProperty { get; set; }
[Required(ErrorMessage = "Type your Message"), DataType(DataType.MultilineText)]
[DisplayName("Message")]
public string MessageProduct { get; set; }
public static IEnumerable<SelectListItem> ProductList()
{
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem { Text = "Printed Fabrics", Value = "1" });
items.Add(new SelectListItem { Text = "Silk Fabrics", Value = "2" });
items.Add(new SelectListItem { Text = "Printed Silk Fabrics", Value = "3" });
return items;
}
內ViewUserControl
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<govindHari.Models.ContactForm>" %>
現在如何調用這裏面
<%= Html.LabelFor(m => m.CityProperty) %>
<%= Html.TextBoxFor(m => m.CityProperty, new { @class = "textBox" })%>
<%= Html.LabelFor(m => m.MobileProperty) %>
<%= Html.TextBoxFor(m => m.MobileProperty, new { @class = "textBox" })%>
<%= Html.LabelFor(m => m.ProductProperty) %>
<%= Html.DropDownListFor(m => m.ProductProperty)%>
的問題是它不是爲我工作,即使我從HomeController的把它從索引頁
請給我幫助
它怎麼不工作? – 2011-12-15 20:48:17