Welcome to imar.spaanjaars.com

image
Welcome to the personal web site of Imar Spaanjaars where I write about software development with a focus on Microsoft web technologies
Image representing the Snippets category

Sending Attachments Directly From a FileUpload Control

Published 17 years ago

With previous versions of ASP.NET you couldn't attach an uploaded file directly to a mail message. Instead, you needed to save the file to disk, attach it to the mail message and then when sending the message succeeded you had to clean up the old file again.

This not only meant a lot of work, it also had some security implications. Because the file needed to be written to disk, the account used by the web server required write permissions to a folder to store the attachments.

Now, with the new constructors for the Attachment class from the System.Net.Mail namespace, these problems are gone....

Read on ...
Image representing the Articles category

Building a Simple Rating Control for ASP.NET 2.0

Published 17 years ago

UPDATE: 16-7-2008 I have updated the control and wrote a new article about it. This new release fixes a few bugs and comes with a better sample web site to try out the control. Check out the new article here.



To show visitors of your site how other visitors feel about the content you're presenting on your site, it's good idea to let your visitors rate your content.

Many web sites take this approach. For example, Amazon uses a 5 star rating approach to rate the articles they're selling. Microsoft's MSDN site uses a nine-bar graph to display the quality of their (technical) articles. My own site uses a five-bar graph to let users rate an article (in the left hand column). Since there are many uses for a rating feature, it makes sense to encapsulate the rating mechanism in a custom ASP.NET Server Control. This article shows you how to build such a control.

Read on ...
Image representing the Articles category

Changing the Login Control to Display a List of Users

Published 17 years ago

A while ago I saw this post on the P2P Wrox forum (near the middle of the thread) where the poster asked for a way to replace the standard TextBox in the asp:Login control with a list of user names from the system. He didn't mind the lowered security implications of this solution and instead wanted to make it a little easier for users to login. With his proposed solution, a user can pick a name from the list, enter a password and log in. I guess fewer things to remember means fewer calls to the helpdesk.

It turns out this is actually quite easy to do.

Read on ...
Image representing the Blogs category

Implemented Google Search

Published 17 years ago

This week I finally had the time to change the Search page of my web site. Up until this week, searches were performed with a custom search solution, that understood a simple form of boolean logic. However, that solution certainly had its limitations.

Read on ...
Image representing the Blogs category

Look, It's Official Now - I Am the 'Owner' of a Zoo

Published 17 years ago

A couple of days ago I received my certificate that states that I am now the owner of zoo in the Netherlands. You don't believe me?

Read on ...
Image representing the Snippets category

Filling a DataTable or DataSet the Quick Way

Published 17 years ago

In .NET 1.x filling a DataSet or a DataTable meant quite some work. You needed to create a Connection object, a DataAdapter and optionally a Command object. Then you had to call the Fill method on the DataAdapter and pass it a newly created DataSet or DataTable.

In .NET 2.0, this code model has been simplified, thanks to the Load method on the DataTable and DataSet classes that takes an IDataReader as a parameter.

Read on ...
Image representing the Articles category

Retrieving the Parameter Marker Format When Using Generic Database Factories

Published 17 years ago

With .NET 2, Microsoft introduced something called DbProviderFactories that allows you to work with databases in a generic fashion. That is, you don't create strongly typed objects like a SqlConnection or an OleDbConnection at design-time, but defer the decision what object to create till run-time. This way, you can write code that works against a number of different databases, like SQL Server, Oracle and OleDb databases like Microsoft Access.

One of the big differences between how these databases operate is the way you must name the parameters you send to a stored procedure or query. For example, SQL Server uses the @ symbol (@userName) and even allows you to leave out a prefix altogether. Microsoft Access in turn uses a question mark without a specific name while Oracle uses a colon as the prefix. Now, how do you deal with these differences when you don't know what database you're working with till run-time?

Read on ...
Image representing the Articles category

Using the Microsoft Access Providers to Replace the Built-In SQL Server Providers

Published 17 years ago

Update 2011/1/9: I just published a short article that shows you how to use the Microsoft Access Providers in an ASP.NET 4 web site.

The biggest features brought by ASP.NET 2.0 are most likely the new services for membership, roles, personalization and profiles. These services supply you with a lot of functionality out-of-the-box with little to no custom code. The services that ship with .NET 2.0 all use SQL Server as the data store (either the Express edition, or the full commercial versions) by means of a provider. But what if you can't use SQL Server, for example because your hosting company doesn't support it? In that case, you can use the Microsoft Access Providers, a shared source initiative released by Microsoft that allows you to use a Microsoft Access database for all the provider based features.

This article shows you how to acquire, compile and use these Microsoft Access Providers.

Read on ...
Image representing the Snippets category

Easily Embed a Windows Media Player in a Web Page

Published 17 years ago

I keep forgetting the code that's required to embed a Windows Media Player movie in a web page, so I decided to add it to my Snippets collection for easy reference.

Read on ...
Image representing the Blogs category

IKEA and the Art of Manual Writing

Published 17 years ago

I just finished assembling an IKEA audio rack and I couldn't stop thinking about how great the concept of IKEA's manuals is. I wish hardware and software manufacturers were able to achieve the same effectiveness with their manuals.

Read on ...

Mobile: False

Crawler: True

I: False