I've come to an MVC3 project I wrote just a week ago which has stopped working and is throwing the following error:
Error 10 The call is ambiguous between the following methods or properties: 'System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(System.Web.Mvc.HtmlHelper, string)' and 'System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(System.Web.Mvc.HtmlHelper, string)
'
What is the reason for this? I haven't changed anything in project recently for it to bork. The code I call it in looks like this:
<div class="page-body">
@if(!String.IsNullOrWhiteSpace(ViewBag.ErrorMessage)) {
// Output error message
Html.Raw(ViewBag.ErrorMessage);
} else {
// Render upload form
Html.RenderPartial("_UploadForm");
}
</div>
You are missing @ symbols front of your Html.Raw because teh method reutrns a string back hence requires the @symbol
For your knowledge taken from MSDN : The Razor syntax @ operator HTML-encodes text before rendering it to the HTTP response. This causes the text to be displayed as regular text in the web page instead of being interpreted as HTML markup.
Please use it this way
<div class="page-body">
@if(!String.IsNullOrWhiteSpace(ViewBag.ErrorMessage)) {
@Html.Raw(ViewBag.ErrorMessage);
} else {
// Render upload form
Html.RenderPartial("_UploadForm");
}
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.