hariaspind
asked on
File Upload & Download using ASP.net 3.5 & MVC2.0
I am trying upload file using the below code .But in the controller HTTPPostedFile is coming as null ? Any solution for this .
<% using (Ajax.BeginForm("Upload", "Attachment", new AjaxOptions { OnSuccess = "ProcessAttachmentUpload", LoadingElementId = "imgAjaxLoader" }, new { enctype = "multipart/form-data" }))
{ %>
<p>
<%= Html.HiddenFor(model => model.RequestID)%>
</p>
<div id="QuestionCreateValidati onMessage" class="validation-summary- errors"></ div>
<table class="Main">
<tr>
<td>
<%= Html.LabelFor(model => model.Name)%>
<%= Html.TextBoxFor(model => model.Name, new { @class = "ui-widget-content" })%>
</td>
</tr>
<tr>
<td>
<input type="file" name="FileUpload" id="FileUpload" value="Uploadfile"/>
</td>
</tr>
</table>
<p>
<input type="submit" class="ui-button ui-state-default" id="btnUpload" value="Upload" />
</p>
<% } %>
<% using (Ajax.BeginForm("Upload", "Attachment", new AjaxOptions { OnSuccess = "ProcessAttachmentUpload",
{ %>
<p>
<%= Html.HiddenFor(model => model.RequestID)%>
</p>
<div id="QuestionCreateValidati
<table class="Main">
<tr>
<td>
<%= Html.LabelFor(model => model.Name)%>
<%= Html.TextBoxFor(model => model.Name, new { @class = "ui-widget-content" })%>
</td>
</tr>
<tr>
<td>
<input type="file" name="FileUpload" id="FileUpload" value="Uploadfile"/>
</td>
</tr>
</table>
<p>
<input type="submit" class="ui-button ui-state-default" id="btnUpload" value="Upload" />
</p>
<% } %>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's hard to use Ajax.BeginForm.So Now i am using the HTML.Begin Form ,as in the sample.Works good .
ASKER
Thanks
ASKER
I am trying to use
<% using (Ajax.BeginForm("Upload", "Attachment", new AjaxOptions { OnSuccess = "ProcessAttachmentUpload",
because i am trying to use the AjaxOptions { OnSuccess = "ProcessAttachmentUpload",