Posts

ASP.NET: Binding alphabet to dropdown list

Update: Added VB code. There may be some cases where you want a DropDownList to list all the letters in the alphabet (i.e. A - Z). Rather than add the letter individually (through using <asp:ListItem> ) you can create an ArrayList and bind to that. In your ASPX page: <asp:DropDownList ID="Letters" DataSource='<%# Alphabet %>' runat="server" /> In your code behind. Create your Alphabet property: private ArrayList _Alphabet; protected ArrayList Alphabet { get { if (_Alphabet == null) { _Alphabet = new ArrayList(); for (int i = 65; i < 91; i++) { _Alphabet.Add(Convert.ToChar(i)); } } return _Alphabet; } } Protected ReadOnly Property Alphabet() As ArrayList Get If _Alphabet Is Nothing Then _Alphabet = New ArrayList() For i As Integer = 65 To 91 - 1 _Alphabet.Add(Convert.ToChar(i)) Next End If Return _Alphabet End Get End Property Bind on Page_Load: private void Page_Load(object sender...

Adding rounded corners to your web pages

There are several ways of adding rounded corners to your web page. There is a large list of methods found at Rounded Corners - css-discuss , but also a few other ways using JavaScript (some using jQuery): The first (as far as I am aware) jQuery corner plugin (Dave Methvin) An improved version (Mike Alsup) of the above plugin curvyCorners - anti-aliased corners, supporting borders and background images A modified version of curvyCorners made to work with jQuery. The above plugin was rather big and couldn't be packed , so someone else made a futher modification that reduced its size and enabled it to be packed. Cornerz - smooth, anti-aliased corners. Another jQuery plugin. Anti-aliased, but does not support backgrounds. Rounded corners using <canvas> . <canvas> is a way of drawing/manipulating images via scripting (e.g. draw vector images, transformation, compositing, animations etc). There is a tutorial available on how to use it. Firefox 1.5+, Opera 9+, ...

Free Alternatives to Adobe Reader

As the years have gone by, Adobe Reader (formally Adobe Acrobat Reader) has got bigger (version 5.05 is 8.6MB and will probably still handle many PDF's OK, the latest, 8.1.1 is 22.3MB) and invariably slower with each release. Thankfully there are free alternatives, that are both a smaller download and much faster at opening PDF's. SumatraPDF (< 1MB, still in beta, open source) Foxit Reader (around 2MB download) PDF XChange Viewer (13MB, but still smaller than Adobe Reader and supports comments/annotations, filling in forms and exporting text and images) Alternatively, you could still have Adobe Reader, and use a tool that disables the plugins that slow the startup - e.g. Adobe Reader SpeedUp or PDF SpeedUp (although I haven't tested either of these).

Analyse performance of web pages with YSlow

YSlow is a plugin for Firefox developed by Yahoo that analyses your web pages and reports back on any performance issues (plus gives a grade). There is a performance report (which shows you areas which can be improved), stats (overview of what is loaded, cached/uncached, cookies and number of HTTP requests), components (page, CSS/JS,JPG etc - expiry, if gzip used, response time, ETag and file sizes) and various tools (view all CSS/JavaScript and a JSLint report). This plugin depends on Firebug .

Form Layout Using CSS

I have created a sample for laying out fields within a fieldset (so that the labels are all lined up) - I use a fieldset as they are handy for grouping related fields together. Nothing too fancy, but it can be used as a basic for something better. Works with Internet Explorer 6 and 7, Firefox 2 and Opera 9.02.

Clearing tempororary files

Being a laptop user, disk space can be an issue and temporary files can be one of the things to clear out to free up some space. There are freeware applications that enable you do do this, but you can just use what is built into Windows to do the same thing. It is run from the command line and is the command rd or rmdir , which basically means 'remove directory'. It can be used to remove directories as well as its sub directories and files, by just typing rd C:\MyFolder\ /s /q (the /s switch is to include sub directories and /q prevents the prompt to remove a directory tree). At first, I thought that running it on the temporary folders directory would remove it and somehow break windows, but it doesn't. This is because there are files within that directory that are in use, and as a result, it can't be deleted. However, all the files and sub directories that aren't locked are removed, freeing up space. I use a simple batch file that cleans up the temporary folders...

Sorting Files by Name, Date, FileSize etc (C#)

It is simple to get a list of files in .NET, you simply do: string folder = "c:\\windows\\"; string[] files = Directory.GetFiles(folder); This will get all the files in C:\Windows (does not include subdirectories). However, they are sorted by name (A-Z) and there aren't any options in the GetFiles method to return them in any other order. Luckily, the results are returned as an array and they can be sorted with a custom comparer. I have created a FileComparer class that can be used to sort the files (works in both .NET 1.1 and 2.0): public class FileComparer : IComparer { public enum CompareBy { Name /* a-z */, LastWriteTime /* oldest to newest */, CreationTime /* oldest to newest */, LastAccessTime /* oldest to newest */, FileSize /* smallest first */ } // default comparison int _CompareBy = (int)CompareBy.Name; public FileComparer() { } public FileComparer(CompareBy compareBy) { _CompareBy = (int)compareBy; } int IComparer.Compare( obj...