ASP.NET 2.0 Guest Book Application

by agrace 4. February 2008 12:45

I recently had to create a Guest Book application for our local Tourism website. Googling a decent code sample didn't yield much so I created it from scratch. I'm making the code available at the bottom of this post. In an effort to keep things simple, I am leaving out the back-end administration since it basically uses the same database table. It also means that I do not have to walk through the membership sytem at this time. If I get requests, I may create another post on the admin part and update the code sample accordingly.

Add Comment

This is a Web Application project written in C#. There is a data access layer and a business layer. This may appear redundant for such a simple example as this but it does make for good coding habits! Ideally, one might also create a base page class and inherit from that, thus avoid unnecessary re-factorings later on. The App-Code folder is used to hold the business and data classes. Classes placed here are dynamically compiled which means we don't have to compile them separately.

Guest Book Message

If you place the source files for your classes in the App_Code folder, you must also add a reference to the System.Design assembly in the compilation section of the Web.config file. This reference requires the fully qualified assembly name of the System.Design assembly. You can get the information required for the fully qualified name by running the Global Assembly Cache Tool (Gacutil.exe) that ships with the Windows Software Development Kit (SDK), using the following syntax:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0>gacutil /l System.Design

I still make use of the SqlHelper class which came with the original "Data Access Application Block". Although this has been superceded by the Enterprise Library, I think it's much more appropriate for smaller projects. You can find out more here. When trying to incorporate the SqlHelper class into the project, I received the following error:

error CS0103: The name 'SqlHelper' does not exist in the current context

After you exhaust all that Google has to offer, you can try what I did and hack the project file by changing:

<content Include="App_Code\Data\SqlHelper.cs" />
to
<compile Include="App_Code\Data\SqlHelper.cs" />

Happy Days :-) 

Guest Book

Note that in the real-world you would use a CAPTCHA control. For simplicity I left it out here, but I originally used Peter Kellner's Ultimate CAPTCHA Control. It's easy to use and Peter was on hand to offer email assistance!

Feel free to download the code and use it any way you will!

GuestBook.zip (74.71 kb)

Guest_Book_DB.zip (3.13 kb)

kick it on DotNetKicks.com



Comments (2) -

Harley Davidson Parts
Harley Davidson Parts United States
8/10/2009 10:03:04 PM #

Great, great, great and - did I forget something? Oh, yeah: Great! thanks for sharing that with us. BTW: I'm typing this on my new iphone - love it...

ATANU UPADHYAY
ATANU UPADHYAY India
4/18/2013 6:38:49 AM #

Very good concept Guestbook

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading