我是MVC的新手,并被这个问题所困扰,我有一个带有小联系人表单的ViewUserControl,我已经为这个ContactForm创建了一个模式。
[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-16 04:50:46
它在简单的改变后就开始工作了
m.ProductProperty, (IEnumerable) Model.ProductProperty)%>
https://stackoverflow.com/questions/8526352
复制相似问题