Last post Apr 15, 2012 08:35 AM by francesco abbruzzese
Apr 15, 2012 07:58 AM|abhijithmanipal|LINK
I am stuck with HtmlHelper method, which is not able to render in the browser i know that it si very silly issue but not finding out ...
public static class HtmlHelperExtensions
public static string Span(this HtmlHelper html, string text)
var builder = new TagBuilder("span");
ViewBag.Title = "Home Page";
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>
@Html.Span("This is Index Page")
Interesting thing is in the browser its coming like this
<span id="firstName">This is Index</span>
Apr 15, 2012 08:16 AM|francesco abbruzzese|LINK
if you retur it as string it is automatically Html encoded causing the effect you notice.
You must return
Apr 15, 2012 08:33 AM|abhijithmanipal|LINK
" Cannot implicitly convert type 'System.Web.Mvc.MvcHtmlString' to 'string' " is throwing if you try to that..
Apr 15, 2012 08:35 AM|francesco abbruzzese|LINK
Clearly you have also to change the type returned by your method from string to MvcHtmlString