2009-04-22 50 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

相關問題