Need uploadcontrol in a ajax.beginform using asp.net mvc3 html5 razor

beynumiau

New Member
I've been looking for a long time for this but I'm still stuck, I need to have an upload control where the user can upload a document and give additional information.I've had to do this before without the upload control so what I do is I get an ajax.beginform that will give all the input from the user to the controller and than close the popup trough a onsucces function, so this looks like this:view:\[code\]@using (Ajax.BeginForm("Save", "Documents", new AjaxOptions { HttpMethod = "Post", OnSuccess = "CloseDialog" }, new { @class = "form-inline", id = "FormId" })){ @Html.Label("Description", "Description") <div class="span3"> @Html.TextBoxFor(m => m.Description) </div> }\[/code\]I tried adding there an Html.BeginForm but then I found out that it is not possible to use nested forms so I deleted this.In my controller I have:\[code\]public PartialViewResult Index(string description){ var model = new DocumentsModel{ Description = description}; return PartialView(model);}[HttpPost]public ActionResult UploadFile(HttpPostedFileBase file, string description){ if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath(@"D:\Documentds\"), fileName); file.SaveAs(path); } return RedirectToAction("Index", new { description = description });}\[/code\]Ofcourse because the html.beginform won't work this controlleraction won't work eitherSo my question is how to do this without having to use a html.beginform?
 
Back
Top