How to Make Use of Namespaces in C# and Visual Basic .NET

If you've written any sort of software application of decent size, you'll know that you need to structure your code, most often using object oriented design techniques, to keep your code-base manageable. Some languages such as Java and C# enable developers to write object-oriented applications relatively well out of the box without much extra work. … [Read more...]

How to Display Your Twitter Feed using ASP.NET

UPDATE 3/23/2010 - Ricky from Twitterizer commented below noting that basic authentication will soon go away via Twitter and OAUTH will be required. Note that the code below will only work for a few months. We will post an updated code-example soon. As I write this article, It's about 75 degrees and Sunny outside. When I should be going out on a … [Read more...]

How to Implement an ASP.NET Color Picker

One of the components of the 360 Web Content Management System (website in progress) that I wanted to develop was an events calendar that allowed you to post events into color-coded categories. You can see a demo of it here. At first, I had it so that users would manually enter in a 6-character HTML color code, but it was very non-intuitive for … [Read more...]

How to Validate Email Addresses in C#

I was recently doing doing support for a client that had a newsletter system. The previous employee had neglected to do much in the form of format validation for email addresses from both a user-input standpoint and system-integrity standpoint. Since there were several email addresses in the database that didn't meet the basic conventions of an … [Read more...]

Hash Passwords in C# and Visual Basic Using SHA-512

We recently covered an easy way to hash passwords using SHA-1┬áin .NET using either Visual Basic or C#. In most cases, SHA-1 encryption is "secure enough", but there are some mathematical weaknesses. Microsoft's .NET platform (specifically the System.Security class) allows you to encrypt passwords with a number of differnet algorithms without having … [Read more...]

How to Authenticate a User in Active Directory using ASP.NET

If you're working in an academic or large corporate or government setting, changes are you're going to have a network in place using Active Directory or an open-source equivalent. Every user in the organization will have some sort of an account to use. If you're building an internal web-application or desktop-application, it doesn't make a lot of … [Read more...]

Making Use of Escape Sequences in C# and Visual Basic

When working with strings of text, there are certain characters that you can't represent in a normal string variable because the key required on the keyboard simply doesn't exist or because of how strings are represented in text. Fortunately, modern programming languages provide "escape sequences," or ways to represent certain characters that … [Read more...]

Using System.IO to Create, Read, Rename and Delete Files and Folders in C# and Visual Basic

If you're making use of C# or Visual Basic for Windows Forms, ASP.NET Web Forms or ASP.NET MVC, you have access to a very powerful file-system access library that's included with Visual Studio. The library, System.IO, will allow you to create, rename, edit and delete files and folders on your system. If you are using System.IO in ASP.NET, you will … [Read more...]

How to Format a DateTime in C# / ASP.NET

When I was a new developer making websites in .NET, I ended up doing some pretty screwy things to make date's and time's look how I wanted to. I would do things like: DateTime thisDate = DateTime.Now; string AMPM = String.Empty; if(thisDate.Hour>=12) {AMPM = "PM";} else {AMPM = "AM";} String FormattedDate = (thisDate.Hour%12).ToString() + … [Read more...]