I have always experienced this problem whenever I tried to work with partial views. I have an partial view that has some contents as follows:
_DocumentsPartial.cshtml
<div>
<input type="text" name="txtDocType" />
<input type="file" name="file_Uploader" />
</div>
<input type="submit" id="btnSaveDocument" />
and then I have a viewPage that is main page which is using that partial view::
ViewPage
<div id="tabs-6">
@* *@
@using (@Html.BeginForm("SaveDocumentFile", "PatientTab", FormMethod.Post, new { @id = "form1", @enctype = "multipart/form-data", @target = "iframeID" }))
{
Html.RenderAction("_DocumentPartial");
}
<iframe id="iframeID" name="myIFrame"></iframe>
</div>
I am able to open partial view in the main page successfully. But After I click on submit button which is in partial view, It returns me partialview in the new tab whereas it should maintain the same state ie. page should be the same. But actually, it opens the content of partial view in a new tab of browser as follows::
http://localhost:6695/PatientTab/SaveDocumentFile
Which is not correct.
My controller code is as follows::
public ActionResult _DocumentPartial()
{
return PartialView("../Shared/Partial/_DocumentPartial");
}
public ActionResult SaveDocumentFile(HttpPostedFileBase file_Uploader, string txtDocType)
{
return PartialView("../Shared/Partial/_DocumentPartial");
}