2009-04-22 92 views
0

你可以看到什么GET删除操作方法传递DDW2File对象来查看。是否有可能以某种方式将此对象绑定回ddw2file参数POST删除操作方法?现在我有null它的价值。POST操作方法的参数绑定

的代码片段:

public class DDW2FileController : Controller 
{ 
    ... 

    public ActionResult Delete(string fileName) 
    { 
     return View(repository.GetFile(fileName)); 
    } 

    [AcceptVerbs(HttpVerbs.Post)] 
    public ActionResult Delete(DDW2File ddw2file) 
    { 
     repository.Delete(file); 
     return RedirectToAction("Index"); 
    } 
} 

... 

public class DDW2File 
{ 
    public string Name { get; set; } 
    public long Length { get; set; } 
} 

谢谢!

回答

3

像这样的东西在视图中的一个窗体应该工作,假设您的参数名称是ddw2file根据您的签名。

<%=Html.TextBox("ddw2file.Name")%> 
<%=Html.TextBox("ddw2file.Length")%> 
+0

谢谢。现在也阅读关于ModelBinders ... – 2009-04-22 12:16:27

相关问题