Gridview ToolTrip and Removing HTML Tag from String

protected void gvwTeacherExamBilling_DataBound(object sender, EventArgs e)
{
try
{
foreach (GridViewRow rowItem in gvwTeacherExamBilling.Rows)
{
Label lblWorkId = (Label)rowItem.FindControl("lblWorkId");
TextBox txtNoOfScriptAndStudent = (TextBox)rowItem.FindControl("txtNoOfScriptAndStudent");
TextBox txtCtNo = (TextBox)rowItem.FindControl("txtCtNo");
TextBox txtGroupMember = (TextBox)rowItem.FindControl("txtGroupMember");
// Tool Trip Test
Label lblWorkName = (Label)rowItem.FindControl("lblWorkName");
Label lblRemarks = (Label)rowItem.FindControl("lblRemarks");
lblWorkName.ToolTip = ParseOutHTML(lblRemarks.Text);
}
}
catch (Exception ex) { }
}

public static String ParseOutHTML(String htmlContent)
{
String parsedContent = String.Empty;
Regex tagPattern = new Regex(@"(?<=^|>)[^><]+?(?=<|$)", RegexOptions.IgnoreCase);
MatchCollection tagsRemoved = tagPattern.Matches(htmlContent);
foreach (Match match in tagsRemoved)
parsedContent += match.Value.Trim() + " ";
return parsedContent;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s