RotatedTextHandler Class
Description
The RotatedTextHandler class is a Handler (a class that implements System.Web.IHttpHandler) that generates a gif image of rotated text. The RotatedTextHandler class can be used by itself or you can use it with the RotatedTextImage control.
Properties & Methods
RotatedTextHandlerThe RotatedTextHandler is a Handler that generates a gif of rotated text. The RotatedTextHandler gets registered in the Web Application's Web.config (see comment at beginning of source code), the URL will be of the format /RotatedTextHandler.ashx?property=value. Listed below are the properties that may be included in the querystring passed to RotatedTextHandler.ashx.
  • Rotation - The angle, specified in degrees, that the text is to be rotated
  • Text - The text that is to be rotated
  • FontColor - The color in which the text is to be drawn
  • BackgroundStyle - The value of a member of the NathanSokalski.RotatedTextHandler.BackgroundStyle enumeration. This will be 0, 1, or 2
  • Background - The color used for the background. This property is ignored if BackgroundStyle has a value of 0 (Transparent)
  • FontStyle - An integral value specifying a System.Drawing.FontStyle. This may be any value from 0 to 15
  • Bold - A Boolean value specifying whether the text should be bold. This property is ignored if the FontStyle property is used
  • Italic - A Boolean value specifying whether the text should be italicized. This property is ignored if the FontStyle property is used
  • Strikeout - A Boolean value specifying whether the text should be strikeout. This property is ignored if the FontStyle property is used
  • Underline - A Boolean value specifying whether the text should be underlined. This property is ignored if the FontStyle property is used
  • FontName - The name of the font to use when drawing the text
  • Size - The size to use when drawing the text
BackgroundStyle As ByteAn enumeration used to specify what part of the background should be colored.
  • Transparent - None of the background should be colored
  • TextOnly - Only the area behind the actual text should be colored. This will end up creating a rotated rectangle in the same position as the text
  • Complete - The background of the entire area used by the generated image will be filled
Source Code
RotatedTextHandler.vb:


(NOTE: Be sure to register the handler in the <httpHandlers> section of the Web Application's Web.config file as noted in the comment at the beginning of the source code)
Remarks
In most cases, I recommend using the RotatedTextImage control rather than create the URL by hand.