.NET, Technology

How to write to the Windows event log using .NET

In the .NET framework you have the System.Diagnostics.EventLog class which provides static methods for working with the Windows event log. Read More »

C#, Technology

The C# break statement

In C# you have the break statement which is most often seen in relation to terminating a switch statement. However it can also be used to terminate any loop statement as follows:

for (int i = 0; i < 10; i++)
{
	if (i == 5) break;
}

If you have nested loop- or switch statements, then the break statement will only terminate the closest one.

Design, Technology

Kuler from Adobe Labs

In need of some new colors for my blog, I started searching for a color schema tool and then I came across Kuler from Adobe Labs. As of this writing there are more than 46 000 color schemas available, organized by tags, names, popularity and rating. All of them are created by the Kuler users.

AJAX, Technology

Create a global progress bar for your ASP.NET AJAX applications

In ASP.NET AJAX you can use the UpdateProgress control to display a progress bar for asynchronous page updates. This control needs to be attached to a single UpdatePanel. If you need a consistent progress bar throughout your application, you will thus need to add one UpdateProgress control for every UpdatePanel control. Since this is not an ideal solution, then instead of using the UpdateProgress control, we can create our own progress bar by attaching a method to the beginRequest and endRequest event of the PageRequestManager class, which toggles the visibility of a div-container with an animated image. Have a look at the example below. Read More »

Architecture, Technology

GUID vs. int (Uniqueidentifier vs. identity)

I got interested in GUID’s when I saw it was used in the ASP.NET membership database schema. At the first glance, 0D40FC92-4F1D-42D1-9A9B-860526C21FF0 didn’t seem very nice, but eventually I realized how flexible and effective the GUID datatype is. So let’s have a look at why you should use it instead of identities (int) Read More »

ASP.NET, SQL Server, Technology

How to store files in a MS-SQL Server database using ASP.NET

In this post we will take a look at how to store data in a MS-SQL Server database using ASP.NET. We will start by creating the database table in which we will store the actual file data, and then create a new Web Form with a file upload control and an upload button which will save the uploaded file to the database. After that we need to create a generic HTTP Handler which will be responsible for flushing out the file to the client. The reason to why we will use a HTTP Handler for this is that we don’t need all the functionality that the System.Web.UI.Page provides, so having both performance and simplicity in mind a HTTP Handler is a better choice. Read More »

SQL Server, Technology

Select random rows from a MS-SQL Server table

Imagine you have a Product table, where you need to get a list of say 5 random products. This is how you can do it:

select top 5 *
from Product
order by newid();

So what actually happens is that newid() returns a new GUID/unique identifier for every row in the result set, it then sorts based on the GUID value and then eventually selects the 5 top most rows.

ASP.NET, Technology

Export data to MS Excel using ASP.NET

The simplest way to export data to Microsoft Excel using ASP.NET is to make a tab- and line break delimited string (CSV), which is written out to the client using a HTTP-Handler with the content type set to “application/vnd.ms-excel”. Read More »

Other software, Technology

Solving the Windows Vista disk-read/write issue

After installing Windows Vista for the first time a few months back, I had a problem with it intensively reading and writing to my hard drives. Not only did it make me worried about the lifetime of my disks, but the sound from it was crazy. Read More »

C#, Technology

How to avoid .NET naming collisions

In order to avoid .NET naming collisions you can use a namespace- or class alias. Read More »

« Newer PostsOlder Posts »