ASP.NET MVC 2 - Binding To Abstract Model

前端 未结 3 762
独厮守ぢ
独厮守ぢ 2020-12-09 05:36

If i have the following strongly-typed view:

<%@ Page Title=\"\" Language=\"C#\" MasterPageFile=\"~/Views/Shared/Site.Master\" Inherits=\"System.Web.Mvc.V         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 06:12

    Just to throw it out there - I'm very much interested in what others might answer, but this is what I ended up doing in the case where I had a similar situation;

    Basically, I did not use the model class as a parameter in the Action method, instead passing in FormCollection and testing a couple known discriminators to figure out which type to create/edit, then used TryUpdateModel from there.

    It seemed there might be a better way, but I'd never gotten around to thinking about it more.

提交回复
热议问题