Free Information Technology Magazines and eBooks

Monday, April 04, 2011

ASP.NET: Vertical Text in Web Pages

We have a new web project that requires a lot of table designing. One of the requirement is to display a cell with a vertical text on it. My initial idea is to just create an image for each text that are already in vertical format but this prevent us from adding new texts on the fly. After searching for a sample code, I found one and I feel sharing it to you in case you may need it in the future. The sample code is hosted at codeproject.com so you need an account to download it. One trick you would see in the code is the use of Response.ContentType = "image/png";. Instead of returning HTML content, it returns a picture. The VerticalText.aspx accepts the following parameters:

Text - the text to be displayed in vertical position.
Font - (font-face|font-size|font attributes).
BgColor - the background color.
FrColor - the fore color of the text.
Padding - the padding between letters of the text.



The project is written in C#.

Download Vertical Text @ Codeproject

To stay up-to-date on Coding Tips & Tricks, subscribe now.

1 comments:

J. Moreno said...

Any reason not to use CSS to do the rotation instead?