Introducing the RoundedCorner Web Control
IntroductionMany professionally done sites group related options into aesthetically-pleasing "boxes". On Amazon.com, for example, the left-hand column contains a number of these boxes: Search, Browse, and so on. Each box has a bordered outline, with a title at the top. To gussy things up a bit, the title bar at the top of the box has rounded corners, as opposed to just square corners.
This is an example of text inside of a RoundedCorners control that has a width of 150 pixels. Neat, eh?
Creating a box with rounded corners isn't terribly difficult, and there's a myriad of ways for creating such design elements. Virtually all of the techniques, though, require using Photoshop or some other graphics editing program to create rounded corners of the appropriate color. For graphics designers, creating rounded corners must be extremely boring, and they likely hold as much interest in creating rounded corners as veteran ASP.NET developers do in creating a connection to a database. Been there, done that - thousands of times. But for non-graphics designers (like yours truly), creating these rounded corners can be frustratingly slow and annoying, especially if you're like me, and the only graphics editing program you have is Microsoft Paint.
To overcome this loathsome activity, I decided to create a custom ASP.NET server control that would utilize the dynamic image-creation capabilities of GDI+ to create the corner images for me. The result is an ASP.NET Web control, which I call RoundedCorners, that you can drop on an ASP.NET Web page, set a few properties, and be presented with a nifty box with rounded corners, as shown on the right. In this article we'll examine how to use the RoundedCorners Web control in a page, as well as take a peek under the covers at the control's source code.
Techniques for Creating Boxes with Rounded CornersBefore we delve into how to use the RoundedCorners control, let's first discuss some of the techniques that can be employed to create a box with rounded corners:
Create the box, rounded corners, and text, all as a single image.
Use a three-column, three-row HTML
Happy Programming!
Attachments:
Download the complete code (in ZIP format)
View a live demo
