locked
MVC 2 generic model RRS feed

  • Question

  • Hello,

    Context:
    I have a create view that is supposed to be generic, for each type T passed as a model to the view, it renders a specific partial view. This partial view only contains the form for creating. This is what it should look like:

    Shared/Create.aspx:

     

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Namespace.ModelDefinition<T>>" %>
    
    ... code ...   
    
     <% Html.RenderPartial(this.Model.Path, this.Model.Model); %>
    
    ... code ...

     

    Name/Create.ascx:

     

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Namespace.Models.Name>" %>
    
        <% using (Html.BeginForm()) { %>
    
    	... code ...
    
        <% } %>

    The 'Name' represents each of the entities that will have a create.ascx

    Is there anyway this could be done? If not, is there anything that will keep it generic like this?

    Thanks,

    Matheus Simon.


    Phrases.Add("Whether you think you can or cannot, you're right.","Henry Ford");
    • Moved by liurong luo Wednesday, October 13, 2010 7:01 AM off-topic (From:ADO.NET Entity Framework and LINQ to Entities)
    Friday, October 8, 2010 6:19 PM

Answers