Hi guys,
I'm trying to render a partial ascx view within another view.
I have the following error however in my ascx file, and after some research I'm still in the dark!:
Type or namespace definition, or end-of-file expectedend-of-file expected
Here is the code in DinnerForm.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NerdDinner.Models.Dinner>" %>
<%: Html.ValidationSummary("Please Corrent the Errors and Try Again.") %>
<fieldset>
<legend>Fields</legend>
<table border="0">
<tr>
<td><%: Html.LabelFor(m => m.Title) %></td>
<td><%: Html.TextBoxFor(m => m.Title) %></td>
<td><%: Html.ValidationMessageFor(m => m.Title, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.EventDate) %></td>
<td><%: Html.TextBoxFor(m => m.EventDate) %></td>
<td><%: Html.ValidationMessageFor(m => m.EventDate, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.Description) %></td>
<td><%: Html.TextAreaFor(m => m.Description) %></td>
<td><%: Html.ValidationMessageFor(m => m.Description, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.Address) %></td>
<td><%: Html.TextBoxFor(m => m.Address) %></td>
<td><%: Html.ValidationMessageFor(m => m.Address, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.Country) %></td>
<td><%: Html.DropDownListFor(m => m.Country, ViewData["countries"] as SelectList)%></td>
<td><%: Html.ValidationMessageFor(m => m.Country, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.ContactPhone) %></td>
<td><%: Html.TextBoxFor(m => m.ContactPhone) %></td>
<td><%: Html.ValidationMessageFor(m => m.ContactPhone, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.Latitude) %></td>
<td><%: Html.TextBoxFor(m => m.Latitude) %></td>
<td><%: Html.ValidationMessageFor(m => m.Latitude, "*") %></td>
</tr>
<tr>
<td><%: Html.LabelFor(m => m.Longitude) %></td>
<td><%: Html.TextBoxFor(m => m.Longitude) %></td>
<td><%: Html.ValidationMessageFor(m => m.Longitude, "*") %></td>
</tr>
<tr>
<td><input type ="submit" value="Save" /></td>
</tr>
</table>
</fieldset>
<% } %>
And here is an example of how I am using it in a file called create.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Host a Dinner
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Host a Dinner</h2>
<% Html.RenderPartial("DinnerForm"); %>
<div>
<%: Html.ActionLink("Back to List", "Index") %>
</div>
</asp:Content>