RenderPartial cannot be converted to string
I am working with a Telerik MVC Tabstrip tester and I have a problem, although I suspect the problem is that I no longer know how to properly use lambda expressions and MVC helpers, not Telerik specific ones.
My helper call:
<% Html.Telerik().TabStrip()
.Name("BusinessDetailsTabs")
.Items(parent =>
{
parent.Add()
.Text("Facilities")
.Content(() =>
{%>
<%= Html.RenderPartial("~/Views/Shared/DisplayTemplates/BusinessRelations/FacilityGrid.ascx", new FacilitiesViewModel {Entities = Model.Facilities}) %>
<%});
})
.Render();
%>
The problem is that the signature of the method Add().Content
Content(string foo)
and apparently the way I'm calling RenderPartial
it just doesn't work - I get this exception: Compiler error message: CS1660: Can't convert the lambda expression to type 'string' because that it is not a delegate type
How can I fix this so that I can still call this partial method? I looked around and found the RenderPartialToString method, but this sounds like a hack and it looks like a better solution than this.
a source to share
Change to
<% Html.Telerik().TabStrip()
.Name("BusinessDetailsTabs")
.Items(parent =>
{
parent.Add()
.Text("Facilities")
.Content(() =>
{
Html.RenderPartial("~/Views/Shared/DisplayTemplates/BusinessRelations/FacilityGrid.ascx", new FacilitiesViewModel {Entities = Model.Facilities});
});
})
.Render();
%>
a source to share