ASP.NET Model Binder and base type

Posted by user137348 on Stack Overflow See other posts from Stack Overflow or by user137348
Published on 2010-03-23T13:09:46Z Indexed on 2010/03/23 13:13 UTC
Read the original article Hit count: 384

Filed under:
|
|
|
|

My model inherits from an interface:

public interface IGrid
{
    ISearchExpression Search { get; set; }
    .
    .
}

public interface ISearchExpression 
{
    IRelationPredicateBucket Get();
}

The model:

public class Project : IGrid
{
      public ISearchExpression Search { get; set; }

      public Project()
      {
            this.Search = new ProjectSearch();
      }  
}

The ProjectSearch:

public class ProjectSearch: ISearchExpression 
{
    public string Name { get; set; }
    public string Number { get; set; }

    public IRelationPredicateBucket Get()
    {...}
}

And the strong typed partialview in the main view:

       <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectSearch>" %>

       <%= Html.TextBoxFor(x=>x.Name)%>

       <%= Html.TextBoxFor(x => x.Number)%>

       ....

When I submit the form, the Search property don't get bound properly. Everything is empty.The action takes an argument of ProjectSearch type.

Why the Search don't get bound as supposed ?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc