views:

79

answers:

3

my viewmodel

public class CaseCreateInput
    {

        [PartialView("My")]
        public object AreaId { get; set; }
}

My.aspx partialview

<%@ Page Title="" Language="C#" MasterPageFile="Field.Master" 
Inherits="System.Web.Mvc.ViewPage<PropertyViewModel<object>>" %>
<%@ Import Namespace="MvcContrib.UI.InputBuilder.Views"%>

<asp:Content ID="Content1" ContentPlaceHolderID="Label" runat="server"><label for="<%=Model.Name%>"><%=Model.Label%></label></asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Input" runat="server">
<%=Html.DropDownList(Model.Name,Model.Value as IEnumerable<SelectListItem>)%></asp:Content>

and when I do

Html.Input(o => o.AreaId) it's actually looking for the Guid.aspx instead of looking for My.aspx from \views\shared

+1  A: 

The problem seems to be coming from the fact that the AreaId property is of type object. For example if you change it to string it works fine.

Darin Dimitrov
yes I noticed that, in the previous versions of inputbuilders this was working fine, but now it isn't
Omu
@Omu, I've performed my tests with the latest build of `MvcContrib` and it worked for me.
Darin Dimitrov
@Darin Dimitrov, I'meant for the properties of type object
Omu
Right, I didn't get it :-) Now the logical question that comes is do you really need weakly typed properties in your view models?
Darin Dimitrov
@Darin Dimitrov yes, I'm doing this for a long time and it's working perfectly, I use it for lookups because I put in my viewmodel a value of type IEnumerable<SelectListItem> and I receive a string[] containing the selected value(s)
Omu
A: 

I guess that the file My must be .ascx and not .aspx. It doesn't?

Kim Tranjan
No, it actually has a masterpage and content placeholders so it's not ascx
Omu
+1  A: 

I switched to mvc 2 Templated Helpers, now it works

Omu