However, when I click the submit button on this view that renders the partial view, the actual form post does not kick off and /PhotoUpload/Upload is not called. However if I put a submit button in the partial view, it works fine, but I do not want that
as I need validation on the create form for all the other fields besides the file upload location.
Why you didn't put a submit button in partial view directly? You mentioned that you need the validation on the create form for all other fields besides the upload location, can you explain that a little bit more?
Romiko
0 Points
1 Post
MVC 3 - Razor - Partial View - File Upload
Oct 19, 2010 02:06 AM|LINK
Hi,
I am trying to use a partial view for a file upload in a Create View.
Here is my partial view, I removed the submit button, as the view it is rendered in, should activat the form post:
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">@model dynamic</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><form action="/PhotoUpload/Upload" method="post" enctype="multipart/form-data"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <input type="file" name="file" /></div>@model dynamic
<form action="/PhotoUpload/Upload" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
I then inject this into my create view:
<div class="editor-label">
FileUpload
</div>
@{Html.RenderAction("Edit", "PhotoUpload"); }
However, when I click the submit button on this view that renders the partial view, the actual form post does not kick off and /PhotoUpload/Upload is not called. However if I put a submit button in the partial view, it works fine, but I do not want that as I need validation on the create form for all the other fields besides the file upload location.
Any ideas?
Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: MVC 3 - Razor - Partial View - File Upload
Oct 20, 2010 03:11 AM|LINK
Hi,
Why you didn't put a submit button in partial view directly? You mentioned that you need the validation on the create form for all other fields besides the upload location, can you explain that a little bit more?
Thanks.