0
我有在訪問我的視圖模型和控制器的局部視圖模型數據複雜的模型和部分景觀
我的模型
public class SearchRequest : BaseRequest
{
public SearchOptions SearchBy{ get; set; }
// and other properties also there
}
[KnownType(typeof(SearchByAirport))]
[KnownType(typeof(SearchByCity))]
[KnownType(typeof(SearchByProductCodes))]
[KnownType(typeof(SearchByGeocode))]
public abstract class SearchOptions
{
}
public class SearchByProductCodes : SearchOptions
{
public List<string> Codes { get; set; }
}
public class SearchByGeocode : SearchOptions
{
// few more properties
}
我查看
查看有問題SearchRequest
的模型參考,並具有選擇搜索類別(即按產品代碼,地理代碼,城市等搜索)的下拉菜單和下拉菜單的變化我加載我的部分觀點
我的一個局部視圖
@model Tavisca.Catapult.External.DataContract.Common.SearchByProductCodes
<div class="form-group">
@Html.LabelFor(model => model.Codes, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Codes)
</div>
</div>
控制器
[HttpPost]
public ActionResult Create(SearchRequest hotelSearchRequest)
{
return View();
}
我得到SearchBy
空在這裏,什麼是安排我的觀點,並得到所有的最好的方法從視圖到控制器的字段。