Skip to content

Instantly share code, notes, and snippets.

@DavidVotrubec
Created October 19, 2011 09:36
Show Gist options
  • Save DavidVotrubec/1297852 to your computer and use it in GitHub Desktop.
Save DavidVotrubec/1297852 to your computer and use it in GitHub Desktop.
Get text value from HtmlTextWriter
var sb = new StringBuilder();
var sw = new StringWriter(sb);
using(var writer = new HtmlTextWriter(sw))
{
writer.AddAttribute(HtmlTextWriterAttribute.Href, someUrl);
writer.AddAttributeValues(HtmlTextWriterAttribute.Class, "actionCell", "download");
writer.AddAttributeIf(Target != null, HtmlTextWriterAttribute.Target, Target);
writer.RenderBeginTag(HtmlTextWriterTag.A);
writer.WriteEncodedText("Download");
writer.RenderEndTag();
return sb.ToString();
}
@DavidVotrubec
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment