HtmlEncode error on a generated view
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"&g开发者_C百科t;
<%: 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>
<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.
精彩评论