Today, a good user interface must have a nice look, too. As the iPhone shows, using an application must be some kind of fun.

In order to create such GUIs, the controls provided by the .NET Compact Framework are lacking a lot of functionality. However, the MSDN gives us some hints: in this article, they show us how to create a button filled with a gradient background.

When using gradients from RGB(238, 238, 238) to RGB(128, 128, 128) one can reach pretty nice results. Furthermore, it is possible to only fill the upper 10 pixels of a black button with a gradient from black to white using the StartOffSet and EndOffSet property. This way, you get buttons similar to the ones currently used by HTC for their TouchFlo user interface.

Well, what about adding rounded corners to the gradient filled buttons? This is far more easy that you might think. I have added a code example on my community Gradient Button Code.
Simply copy the code located in the linked topic. It must be inserted at the end of the function DrawImage from the original example out of the MSDN.
The idea is to draw the border manually instead of just adding a rectangle around the button. At each corner, we “dash” the border by one pixel to achieve the look of a rounded corner. That’s all the trick!

If you have ever wondered what the nice color names from the .NET Color structure in namespace System.Drawing.Color actually mean, you will find this page very useful.
They present a listing of the named colors in .NET, show how they look like and also specify the corresponding hexadecimal values.

There are many scenarios where a web application must serve a file instead of a response containing HTML output to be rendered by the browser.

This little tip illustrates how to cause the browser to display a file download dialog instead of trying to display the data directly (which fails in most cases, especially with binary data).

As you will see, the whole magic concentrates on a special HTTP header, so this tip can be used with any technology and framework, ranging from Java Server Faces (JSF) and the Seam framework to PHP and even ASP or ASP.NET.

A common way to realize file download is to simply write the file data into the HTTP response.

However, if you have to handle arbitrary files, you are not able to set a specific Content-Type header like text/plain or something else.

So the client (namely the browser) has no idea what kind of data it actually receives and what to do with it.

Here is where the HTTP header Content-Disposition comes into play. Setting this header tells the client that an attachment is received and therefore causes the browser to display a file download dialog.
Now it’s the user’s responsibility to save the file and to open it with a corresponding application.

The Content-Disposition header consists of two values: the string “attachment” indicating an attachment and a “filename” property specifying a filename for the attachment. Usually, the browser takes this value as proposed filename in the download dialog.

The following line is an example extract from an HTTP response containing a Content-Disposition header:

Content-Disposition: attachment; filename="myFile.exe"