2012-10-01 165 views
0

我需要將表單值傳遞給我的控制器加上我正在使用的型號。用BeginForm將值傳遞給控制器​​

發佈到控制器時,下面的語法是否正確?

HTML

@using (Html.BeginForm("GeneratePDF", "Home", FormMethod.Post)) 

控制器

public ActionResult GeneratePDF(FormCollection values, ViewModelTemplate_Guarantors tg) 

回答

0

你能不能既包括爲特定視圖模型?類似於

public GeneratePDFModel 
{ 
    public string FormCollectionValueFoo {get;set;} 
    public string FormCollectionValueBar {get;set;} 
    ViewModelTemplate_Guarantors OtherModel {get;set;} 
} 

或來自ViewModelTemplate_Guarantors

public GeneratePDFModel : ViewModelTemplate_Guarantors 
{ 
    public string FormCollectionValueFoo {get;set;} 
    public string FormCollectionValueBar {get;set;} 
} 

這樣一切都是強類型的。