Again, thanks for the link. I was able to modify the RenderedHTML by using the method below in my own custom created webpart. I haven't tested one thing though, when does the class="" get assigned? What I want to do is create my css class and have it assign like the other classes do but for my newly created <span> tag. Will I have to set that manually or will it be set automatically?
/// <summary>
/// OnLoad override (set span tag inside of a link for navigation)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Page_Load(object sender, EventArgs e)
{
this.menuElem.LoadDataAutomaticaly = false;
string menuHtml = this.menuElem.RenderedHTML;
// get the space between <a> and </a> to place a <span> tag in place.
string pattern = "<a[^>]*? href=\"(?<url>[^\"]+)\"[^>]*?>(?<text>.*?)</a>";
System.Text.RegularExpressions.Regex regexObj = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match(menuHtml, pattern,
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline);
string returnHtml = "";
while (match.Success)
{
string strMatch = match.Groups[2].ToString();
string newText = "<span>" + strMatch + "</span>";
returnHtml = menuHtml.Replace(">" + strMatch + "</", ">" + newText + "</");
menuHtml = returnHtml;
match = match.NextMatch();
}
this.menuElem.RenderedHTML = returnHtml;
}