Scott on Writing

Musings on technical writing...

RoundedCorners Web Control Update

A couple weeks ago I created a custom ASP.NET server control for displaying some text within a box with rounded corners. This control, which I called RoundedCorner, was discussed in detail in the article Introducing the RoundedCorners Web Control. Ideally, such rounded corner boxes are created by having a graphics designer create the necessary rounded corner images using Photoshop or some other graphics editing program. The HTML designer, then, can create the necessary markup (HTML and/or CSS) to display a box using these rounded corner images. While this is indeed the "best practices" approach for creating a box with rounded corners, it is not always feasible for those of us who are developer teams of one, and whose artistic skills match those of a brain-damaged poodle. The RoundedCorners Web control aids those of us, like me, who fall in this boat by dynamically creating the corner images using GDI+.

Since the publication of the original RoundedCorners article, I have received a lot of great feedback on suggestions for improvements. The main two suggestions were:

  1. Add the ability to put anything inside a box with rounded corners, not just some text message. That is, I should be able to have a DataGrid, some HTML markup, and a TextBox Web control all within a RoundedCorners Web control instance.
  2. Use anti-aliasing when generating the images, to help smooth out the rounded corners.

I have implemented these two enhancements, and recently wrote an article on 4Guys with information about my experiences. You can read the article at Improving the RoundedCorners Web Control, which contains the complete source code. Also be sure to check out the updated live demos.

posted on Monday, August 09, 2004 2:49 PM

Feedback

# re: RoundedCorners Web Control Update 8/9/2004 4:04 PM Paul Wilson

Nice updates. Great job.

# re: RoundedCorners Web Control Update 8/10/2004 5:47 AM James Avery

This is awesome Scott. I downloaded the original and turned on anti-aliasing, but I did not notice a difference... can you notice a difference? Maybe it is my resolution but they look exactly the same to me.

-James

# re: RoundedCorners Web Control Update 8/10/2004 6:11 AM AndrewSeven

I posted a thought here : http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=656203

Essentialy you don't put the control that needs the corners inside the corners control.
You provide a separate panel based control for the "Content" and then do some crufty stuff to render it somewhere else.

# re: RoundedCorners Web Control Update 8/10/2004 11:31 AM Phil Weber

Hey, now: There's no need to insult brain-damaged poodles! :-)

# re: RoundedCorners Web Control Update 8/11/2004 7:24 AM primortal

awsome, thanks scott for the update.

# re: RoundedCorners Web Control Update 8/11/2004 12:07 PM Scott Mitchell

James, check out the sample at http://scottonwriting.net/demos/RoundedCorners.aspx

To my understanding, anti-aliasing will only occur if there image is "big enough" and if the color contrasts on both sides of the line are different enough. Anywho, if you look at the bottom most example from the link above, you can zoom into the image and see that there are spreckles of pink on the outside of the line, giving it a "rounded" feel.

# re: RoundedCorners Web Control Update 8/11/2004 7:02 PM Patrick Collins

Hi there, this looks like a great piece of work but I seem to have a problem getting it to run.. I'm getting a GDI+ Generic Error:

Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

I thought it might have been a permissions thing but that didn't sort it..

Hope you can help,
Patrick

# re: RoundedCorners Web Control Update 8/11/2004 7:20 PM Scott Mitchell

Patrick, what did you try in order to sort out the permissions thing? The simplest thing is to give full access to the images folder for Everyone. If that does the trick, then you can scale it back for the correct user (which depends on if you're using impersonation and what OS you're using).

# re: RoundedCorners Web Control Update 8/11/2004 7:34 PM Patrick Collins

Sir, you are a gentleman and a scholar.

I had neglected to update the ImageDirectory value - yet another case of the blindingly obvious.

Thanks again,
Patrick

# A Few Interesting System.Drawing Posts 9/8/2004 12:39 AM load of Tosh

# re: RoundedCorners Web Control Update 2/7/2005 1:35 PM Chuck Bryan

Scott,

From one "BDP" to another, thanks!!! One question. I am hosting an "ascx" inside, but my default styles (from a body css class) are not being applied. Any suggestions?

Chuck

# re: RoundedCorners Web Control Update 3/1/2005 11:09 AM Shawn

With the RoundedCorner Web Control, how would I make them into a news feed using C#, I'm new to C# and would like to have 3-5 RoundedCorner Web Controls on a page with different news. I got the control to work, now how would I connect them to a database result?

I know I would use a while loop to iterate through each news record, but in C#, how would I connect it to the roundedcorner web control on my page? Would I use a dataset, and if so, how would that look?

# re: RoundedCorners Web Control Update 5/30/2005 8:28 PM Karin

My question is similar to Chuck Bryan's. (Two posts previous.)
I am using external stylesheets. Is there any way that this control can use a cssclass attribute? (especially for the 'generic' tags like font, border, etc. I don't mind putting this control's specific tags (eg ImageDirectory) inside the roundedcorners tag itself)

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles