Skip to content

Instantly share code, notes, and snippets.

@spurgeonbj
Created February 11, 2023 05:36
Show Gist options
  • Save spurgeonbj/a9ed2ba1640d66cb39a45092f0e97bf2 to your computer and use it in GitHub Desktop.
Save spurgeonbj/a9ed2ba1640d66cb39a45092f0e97bf2 to your computer and use it in GitHub Desktop.
C# Traverse a HTML WebControl to get Inner HTML
HtmlGenericControl myControl = (HtmlGenericControl)this.FindControl("CoursesDataDiv");
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
myControl.RenderControl(htw);
}
}
string markup = sb.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment