Я запускаю коллекцию Items и хочу создать TextBox, но получаю следующую ошибку:
'System.Web.Mvc.HtmlHelper<Web.Module>' does not contain a definition for
'TextBoxFor' and the best extension method overload
'System.Web.Mvc.Html.InputExtenstions.TextBoxFor<TModel,TProperty>System.Web.Mvc.HtmlHelper<TModel>,System.Linq.Expressions.Expression<System.Func<TModel, TProperty>>)' has some invalid arguments
Я думаю, что моя анонимная функция неправильная, но почему?Пожалуйста, помогите мне
SocialNetworkModel класс
public class SocialNetworkModel : IViewModel
{
#region Properties
public List<SocialNetworkItem> Items { get; set; }
#endregion
public SocialNetworkModel(string param)
{
this.Create(param);
}
/// <summary>
/// DO NOT DELETE: default .ctor is used when binding posted data, from client, back to the model
/// </summary>
public SocialNetworkModel() { }
public void Create(string param)
{
Items = new List<SocialNetworkItem>();
foreach(var item in Customer.Current.GetSocialNetworkList())
{
Items.Add(new SocialNetworkItem
{
CodeName = item.CodeName,
Link = item.Link,
UserName = item.UserName,
Password = item.Password
});
}
}
}
public class SocialNetworkItem
{
#region Properties
[LocalizedDisplayName("CodeName", NameResourceType = typeof(Resources.Views.SocialNetwork))]
public string CodeName { get; set; }
[LocalizedDisplayName("Link", NameResourceType = typeof(Resources.Views.SocialNetwork))]
public string Link { get; set; }
[LocalizedDisplayName("UserName", NameResourceType = typeof(Resources.Views.SocialNetwork))]
public string UserName { get; set; }
[LocalizedDisplayName("Password", NameResourceType = typeof(Resources.Views.SocialNetwork))]
public string Password { get; set; }
#endregion
}
ViewUserControl
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Module>" %>
<% var model = Model.Model as SocialNetworkModel; %>
<div id="social-network-container">
<div id="social-network">
<% using (Ajax.BeginForm(Model.CodeName + "FormPost", "Customer", null, new AjaxOptions() { HttpMethod = "POST" }, new { @class = "form-container" }))
{ %>
<%model.Items.ForEach(item => { %>
<%: Html.TextBoxFor<SocialNetworkItem, string>(s => item.Link)%>
<%}); %>
<% }%>
</div>
Спасибо