views:

235

answers:

1

You can see what GET Delete action method passes DDW2File object to view. Is it possible somehow to bind this object back to ddw2file parameter of POST Delete action method? Now I have null value in it.

Code fragment:

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; }
}

Thanks!

+3  A: 

Something like this inside a form in the view should work assuming your parameter name is ddw2file as per your signature there.

<%=Html.TextBox("ddw2file.Name")%>
<%=Html.TextBox("ddw2file.Length")%>
Steve Willcock
Thanks. Now also reading about ModelBinders...
Alexander Prokofyev