I have a HtmlHelper that renders a grid as a table, in MVC2 I would call it from the view using the following syntax…
<%=
Html.MyLibrary().Grid<MyGridItem>()
.Name("MyGrid")
.Width("100%")
.Render()
%>
Notice it uses templates. In MVC3 with Razor it won’t compile, seemingly because the left angle bracket ‘<‘ is being confused for html. To get around this I can enclose it in curly braces…
@{Html.MyLibrary().Grid<MyGridItem>()
.Name("MyGrid")
.Width("100%")
.Render();}
but now the problem is that the string returned from .Render() doesn’t get put in the output stream!
Any help solving this would be much appreciated.
You should use Html.Raw() Method.
The @{…} server side block does not get rendered because it’s simple server side code. Same if you wrote