Unable to use TagBuilder
Hi,
I get this message "The type or namespace name 'TagBuilder' could not be found (press F4 to add a using directive or assembly reference)" but I have added MVC assembly and its namespace. What's wrong ?
Sam
I get this message "The type or namespace name 'TagBuilder' could not be found (press F4 to add a using directive or assembly reference)" but I have added MVC assembly and its namespace. What's wrong ?
void Main()
{
var spanTag = new TagBuilder("span");
spanTag.SetInnerText("Texte à l'intérieur de la balise span");
string resultSpan = spanTag.ToString(TagRenderMode.Normal) + Environment.NewLine;
spanTag.Dump();
}
Sam
Comments
-
Do you have LINQPad Pro or Premium? If so, click the smart tag that appears on TagBuilder. It will let prompt you to add the namespace/assembly.
-
I have the premium version. But I don't see any smart tag in my case. When I put the cursor on TagBuilder I get the message :
The type or namespace name 'TagBuilder' could not be found (press F4 to add a using directive or assembly reference). -
Thank you Joe for the reference and now I have seen the smart tag.
-
I did the following to your code in order to get it working:
void Main() { var spanTag = new System.Web.Mvc.TagBuilder("span"); spanTag.SetInnerText("Texte à l'intérieur de la balise span"); string resultSpan = spanTag.ToString(System.Web.Mvc.TagRenderMode.Normal) + Environment.NewLine; spanTag.Dump(); }
