Hi,
I have a form which uploads a photo to my database, and I use a view model to aid in this process.
View Model:
public class GalleryViewModel
{
//Members:
public Gallery _photo { get; set; }
public string _title { get; set; }
public string _description { get; set; }
public string _photographer { get; set; }
public HttpPostedFileBase uploadFile { get; set; }
// Ctor
public GalleryViewModel(Gallery photo)
{
_photo = photo;
}
public GalleryViewModel()
{
_photo = null;
}
}
When I debug the code, I see that the in the post method in my controller, all the information from the form is updated in the view model except for the uploadFile which is null. In the form I use enctype = "multipart/form-data". When I use my master page the uploadFile is null but when I use the default MVC master page everything works fine.
Here is my master page:
<%@ Master Language="C#" MasterPageFile="~/views/Shared/GeneralMaster.master" Inherits="System.Web.Mvc.ViewMasterPage" %>
<asp:Panel ID="notifiactions" runat="server">
<% if (ViewData["notifications"] != null)
{ %>
<br />
<table width="100%">
<tr>
<td align="center">
<div id="messages" style="width: 90%; border: solid 1px #A3A3A3">
<br />
<%= Html.Encode(ViewData["notifications"])%>
<br /><br />
</div>
</td>
</tr>
</table>
<% } %>
</asp:Panel>
<br />
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" align="center">
<img src="\Content\SiteDesign\wine_in_frame2.JPG" alt="lk" />
</td>
<td width="40%">
<asp:ContentPlaceHolder ID="PageContent" runat="server" />
</td>
<td width="30%" align="right">
<img src="\Content\SiteDesign\set_with_frame.jpg" alt="Alon" />
</td>
</tr>
</table>
Here is the default asp.net mvc master page
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<div id="header">
<div id="title">
<h1>My MVC Application</h1>
</div>
<div id="logindisplay">
<% Html.RenderPartial("LogOnUserControl"); %>
</div>
<div id="menucontainer">
<ul id="menu">
<li><%= Html.ActionLink("Home", "Index", "Home")%></li>
<li><%= Html.ActionLink("About", "About", "Home")%></li>
</ul>
</div>
</div>
<div id="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<div id="footer">
</div>
</div>
</div>
Any Ideas?