Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 15, 2012 12:35 PM by francesco abbruzzese
Apr 15, 2012 11:58 AM|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 12:16 PM|LINK
if you retur it as string it is automatically Html encoded causing the effect you notice.
You must return
Apr 15, 2012 12:33 PM|LINK
" Cannot implicitly convert type 'System.Web.Mvc.MvcHtmlString' to 'string' " is throwing if you try to that..
Apr 15, 2012 12:35 PM|LINK
Clearly you have also to change the type returned by your method from string to MvcHtmlString