Created
October 19, 2011 09:36
-
-
Save DavidVotrubec/1297852 to your computer and use it in GitHub Desktop.
Get text value from HtmlTextWriter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related blog post: http://davidjs.com/2011/10/how-to-get-text-value-from-htmltextwriter-in-csharp/