I want to add a HtmlAnchor to the .ascx control. So far I have the code like this:
private void SetPhoneNumber()
{
HtmlAnchor htmlAnchor = new HtmlAnchor();
const string spanTag = @"<span class=""icon phone"">m</span>";
string anchor = spanTag + Context.CurrentPhoneNumber();
htmlAnchor.InnerText = anchor;
Controls.Add(htmlAnchor);
}
This is not solving my purpose as its showing like this:
When it should be rendered in the HTML, it should look like this:
<a href="tel:888.444.4444" class="phone"><span class="icon phone">m </span>888.444.4444</a>
Can anyone help me out on this?
Set the InnerHtml
of the anchor tag:
HtmlAnchor htmlAnchor = new HtmlAnchor();
const string spanTag = @"<span class=""icon phone"">m</span>";
string anchor = spanTag + Context.CurrentPhoneNumber();
htmlAnchor.InnerHtml = anchor;
Controls.Add(htmlAnchor);