2014-02-25 88 views
0

我有文件上傳控制與一些其他幾個項目發佈到服務器。所以,我有一個包含上述項目的局部視圖。我已將表單目標設置爲Iframe,這只是保留頁面以再次保持狀態但不能正常工作的事情。刷新行動後的視圖中的部分視圖

其實我的要求是刷新部分視圖,以便它獲得最新添加的項目和狀態的頁面也應該保持onclick的提交按鈕。

鑑於頁:

<form action="/Tab/SaveDocumentFile" method="post" enctype="multipart/form-data" target="frame"> 
       @{ Html.RenderAction("_MyPartial");} 
       <iframe id="frame" name="frame" style=""></iframe> 
      </form> 
<script> 
    RefreshGrid();//The method that gets records from table by ajax and bind the grid. 
</script> 

這是局部視圖

<input type="text" name="txtDocName" /> 

    <input type="hidden" id="hdnClientID" name="HdnClient" /> 

    <input type="file" name="file_Uploader" /> 


    <div class="footer"> 
     <div class="footer-heading">Previous documents</div> 
     <div class="footer-heading"> 
      <div id="DocListDiv" style="display: none; margin-top: 2%;"></div> 
     </div> 
    </div> 

</div> 


<input type="submit" id="btnSaveDocument" /> 

控制器

public ActionResult SaveDocumentFile(HttpPostedFileBase file_Uploader, FormCollection collection) 
     { 
After Performing the upload of file 
    return RedirectToAction("_MyPartial", "Tab"); 
} 

,這是_MyPartial方法

public ActionResult _MyPartial() 
     { 

      ViewBag.Type = new SelectList(TypeList, "Id", "Type"); 
      return PartialView("../Shared/Partial/_MyPartial"); 
     } 

回答

0

而不是iframe裏面的表單,如果你可以讓你在iframe中進行局部視圖,然後在你的局部視圖中採用<form>標記,並嘗試發佈,我認爲這將起作用,你只需將iframe源作爲你的局部視圖。