2013-07-16 35 views
0

所以我有這個div在我的asp.net MVC3應用程序用戶可以在其中添加文件,表單提交給我的參數字典包含參數無效項「ClaimID的」

@using (Html.BeginForm("Uploadfile", "Home", FormMethod.Post, new { enctype =   "multipart/form-data" })) { 
     <input type="button" id="btnBrowse" class="btnAttachments" value="@Lang.btnBrowse" /> 
     <input type="file" style="visibility: hidden;" id="btnSave_file" name="files[]" multiple/>     
     <input type="submit" value="Submit" class="btnAttachments"/>      
} 

時提交按鈕被按下我得到的錯誤: prt scrn for the error

因此,在我看來,控制器調用函數ClaimForm。造成這種情況的原因是提交表單是另一種更大的形式,它會調用具有提交表單的視圖。

這怎麼解決?

回答

1

The reason that could cause this is that the submit form is in another bigger form that calls a view

是的,這就是問題所在。不支持嵌套表單,也不建議。將這兩個表單分離出來,你的代碼應該按照正確的控制器動作

@using (Html.BeginForm("ClaimForm", "Home", FormMethod.Post)) 
{ 
    ... 
} 

@using (Html.BeginForm("UploadFile", "Home", FormMethod.Post, new enctype = "multipart/form-data" })) 
{ 
    ... 
} 
+0

的事情是,在Web應用程序:有是調用CLaimOverview視圖,然後調用保存的uploadfile形式NewClaimDetails視圖claimForm視圖。所以不可能把它分開。 – justauser

+0

@justauser它是一個嚮導類型的應用程序,你試圖寫? 「*沒有可能把它分開*」 - 當然,事實上,它有*被拆分,否則它將無法工作。 – James

相關問題