views:

19

answers:

1

I've just set up a small R&D MVC2 project, and I've basically used only the wizards to add a partial view for my Customer object, which as a Linq to SQL entity. When I try and visit the Create view for Customer, I get the following error on the RenderPartial method in the Create view:

Compiler Error Message: CS1502: The best overloaded method match for System.Web.HttpUtility.HtmlEncode(string)' has some invalid arguments

The Create view looks like this:

<fieldset>
    <legend>Fields</legend>
    <%: Html.RenderPartial("CustomerEditorExplicit") %>
    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>

And CustomerEditorExplicit looks like this:

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

etc.

I also have a CustomerEditorModel looking like below, but also gives me the same error:

<fieldset>
    <legend>Fields</legend>
    <%: Html.EditorForModel() %>
    <p>
        <input type="submit" value="Save" />
    </p>
</fieldset>
A: 
<fieldset>
    <legend>Fields</legend>
    <% Html.RenderPartial("CustomerEditorExplicit") %>
    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>

Just remove the Colon after the code blocks before you render your partial.

You may need to add a semi colon to the end of that line too.

jimplode
The colon on the textboxes is fine, but not on RenderPartial, thanks. The return type of RenderPartial is 'void', where TextBoxFor returns a System.Web.Mvc.MvcHtmlString value.
ProfK
Removed textbox from answer
jimplode