views:

254

answers:

1

Hi

I have a View that contains a usercontrol. The usercontrol is rendered using:

<% Html.RenderPartial("GeneralStuff", Model.General, ViewData); %>

My problem is that the usercontrol renders nicely with values from the model but when I post values edited in the usercontrol they are not mapped back to Model.General. I know I can find the values in Request.Form but I really thought that MVC would manage to map these values back to the model.

My usercontrol:

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

<fieldset>        
    <div>
        <%= Html.LabelFor(model => model.Value)%>
        <%= Html.TextBoxFor(model => model.Value)%>            
    </div>
</fieldset>

I'm using .Net MVC 2

Thanks for any help!

A: 

Problem solved!

My usercontrol is rendered with:

<%= Html.EditorFor(model => model.General); %>

My model looks like this:

public class TestEditViewModel
{
    [UIHint("GeneralViewModel")]
    public GeneralViewModel General { get; set; }
}

And my usercontrol is placed under Views->Shared->EditorTemplates and named "GeneralViewModel.ascx"

Andreas