2012-10-01 41 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;} 
} 

这样一切都是强类型的。