title: asp.net MVC6 Implementing a tagbuilder class and get error on ".ToString"
body: <p>I am getting compile errors when attempting to implement the message class from <a href="http://levelnis.co.uk/blog/send-success-message-to-view-using-tempdata" rel="nofollow">Levelnis</a>'s Blog.</p>
  
  <p>The class in question is:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Microsoft.AspNet.Mvc.Rendering;
  
  namespace Notifier.Helpers.MessageNotifier
  {
      public class Message
      {
          public MessageSeverity Severity { get; set; }
  
          public string Text { get; set; }
  
          public string Generate()
          {
              var isDismissable = Severity != MessageSeverity.Danger;
              if (Severity == MessageSeverity.None) Severity = MessageSeverity.Info;
              var sb = new StringBuilder();
              var divTag = new TagBuilder("div");
              divTag.AddCssClass("alert fade in");
              divTag.AddCssClass("alert-" + Severity.ToString().ToLower());
  
  
              var spanTag = new TagBuilder("span");
              spanTag.MergeAttribute("id", "MessageContent");
  
              if (isDismissable)
              {
                  divTag.AddCssClass("alert-dismissable");
              }
  
              sb.Append(divTag.ToString(TagRenderMode.StartTag));
  
              if (isDismissable)
              {
                  var buttonTag = new TagBuilder("button");
                  buttonTag.MergeAttribute("class", "close");
                  buttonTag.MergeAttribute("data-dismiss", "alert");
                  buttonTag.MergeAttribute("aria-hidden", "true");
                  buttonTag.InnerHtml = "×";
                  sb.Append(buttonTag.ToString(TagRenderMode.Normal));
              }
  
              sb.Append(spanTag.ToString(TagRenderMode.StartTag));
              sb.Append(Text);
              sb.Append(spanTag.ToString(TagRenderMode.EndTag));
              sb.Append(divTag.ToString(TagRenderMode.EndTag));
  
              return sb.ToString();
          }
      }
  }
  </code></pre>
  
  <p>I am getting two errors - the first relates to ".ToString" on the line:</p>
  
  <pre><code>sb.Append(divTag.ToString(TagRenderMode.StartTag));
  </code></pre>
  
  <p>and it says:</p>
  
  <pre><code>No overload for method 'ToString' takes 1 arguments
  </code></pre>
  
  <p>The second error relates to the line:</p>
  
  <pre><code>buttonTag.InnerHtml = "×";
  </code></pre>
  
  <p>and it says:</p>
  
  <pre><code>Property or indexer 'TagBuilder.InnerHtml' cannot be assigned to -- it is read only
  </code></pre>
  
  <p>I have had a look at the documentation and other posts but so far I have not found anything that can help me modify this to compile correctly...</p>
  
  <p>Are these methods implemented differently in Asp.net-core and if not can someone suggest another way of doing these lines?</p>