user603007
user603007

Reputation: 11794

'Using' must end with a matching 'End Using'

i am trying to use a Html.RenderPartial but getting an error:

'Using' must end with a matching 'End Using'.

View:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<mvc2Test.Models.Employee>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Create</h2>
    <% Html.RenderPartial("ViewUserControl1"); %>
</asp:Content>

Partial View:

<% using (Html.BeginForm()) {%>
    <%: Html.ValidationSummary(true) %>

    <fieldset>
        <legend>Fields</legend>

        <div class="editor-label">
            <%: Html.LabelFor(model => model.EmployeeID) %>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.EmployeeID) %>
            <%: Html.ValidationMessageFor(model => model.EmployeeID) %>
        </div>

        <div class="editor-label">
            <%: Html.LabelFor(model => model.NationalIDNumber) %>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.NationalIDNumber) %>
            <%: Html.ValidationMessageFor(model => model.NationalIDNumber) %>
        </div>


        <div class="editor-label">
            <%: Html.LabelFor(model => model.ModifiedDate) %>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.ModifiedDate, String.Format("{0:g}", Model.ModifiedDate)) %>
            <%: Html.ValidationMessageFor(model => model.ModifiedDate) %>
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
<% } %>

Upvotes: 2

Views: 3560

Answers (2)

user603007
user603007

Reputation: 11794

i got it i forgot to put this line of code on top of the view:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<mvc2Test.Models.Employee>" %>

Upvotes: 2

Konrad Rudolph
Konrad Rudolph

Reputation: 545568

The error message suggests that the code is parsed as VB, rather than C#. Did you perhaps accidentally specify a wrong language for the partial view?

Upvotes: 6

Related Questions