每當我嘗試使用部分視圖時,我總是遇到此問題。 我有,有一些內容如下的局部視圖:使用部分視圖進行文件上傳
_DocumentsPartial.cshtml
<div>
<input type="text" name="txtDocType" />
<input type="file" name="file_Uploader" />
</div>
<input type="submit" id="btnSaveDocument" />
,然後我有一個的ViewPage就是它是使用局部視圖::
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>
我能打開主頁主頁中的局部視圖成功。但是,當我點擊部分視圖中的提交按鈕後,它會在新選項卡中返回我的partialview,而它應該保持相同的狀態,即。頁面應該是一樣的。但實際上,它會在瀏覽器的新選項卡中打開部分視圖的內容,如下所示:
http://localhost:6695/PatientTab/SaveDocumentFile
這是不正確的。
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");
}
但我不希望整個表單發回。我只需要該部分視圖再次加載。這可能嗎? – Sweetie
那麼你必須做出ajax請求 – Akhlesh
你的意思是說「@Ajax.ActionLink()」? – Sweetie