Force domain.com to redirect to www.domain.com using IIS 6

If you have a SSL on your site chances are that you only want your visitors to go through your site on one particular domain. Let's say you own domain.com and you always want your visitors to go to www.domain.com when using your site. IIS 7 has a really cool rewrite module that you can use but IIS 6 users need to jump through some hoops to get this function working.

For this article I will assume that you have www.domain.com already setup on your server in IIS 6 and that you have setup your SSL to work on this domain. I will also assume that you have setup the host name for your domain to be www.domain.com, your IP address and domain.com.

Your first step is to remove domain.com from the allowed host list for this domain in IIS. To do this just right click on domain.com in IIS and select Properties. Next to the IP address of your domain click the Advanced button. Highlight the host header that has domain.com (no www.) and click remove. Click OK and apply to save and continue.

At this point you might want to rename domain.com in IIS to say domain.com (WWW) to make it clear that this setup of domain.com is for www.domain.com.

Next up add a new domain to IIS. You should name this as domain.com (no WWW) in IIS, again this is only to make it clear when you're looking through your list of domains that this setup is for domain.com without the www. subdomain. Set this up exactly the same as you did for www.domain.com but put domain.com as the host name. Once you have added domain.com to IIS go to its properties and select the Home Directory tab.

  1. Select Redirect to another domain (1).
  2. Remove the application name (2).
  3. Enter in the domain we want to redirect to. In this case it's www.domain.com and add on $S$Q at the end of the domain so that you are specifying to IIS to redirect to the correct folder structure on www.domain.com and to pass through the correct query string values as entered by the user (3).
  4. Tick the checkboxes for The exact URL entered above and Permanent Redirect (4,5).
  5. Click Apply and then OK (6,7).

If you now open your browser and type in domain.com it should automatically redirect you to www.domain.com! If you test with query string values you should see that these also carry through to www.domain.com.

Although this option is not an ideal setup as it duplicates your IIS domain list it will work for you. If anyone knows a better way to achieve the same results in IIS 6 let me know.

 

Dec08

Aquatech.ie and PolarBear.ie kick off Demeber for Dragnet Systems

Aquatech.ie and PolarBear.ie kick off December for Dragnet Systems

It might be the first day of December but that hasn't stop us from launching 2 new websites to get our December releases off to a great start! Aquatech Ireland have launched 2 new online stores and a brochure site to open up their products to customers all around the world. Aquatech.ie are one of Irelands leading suppliers of renewable energy systems and alternative heating solutions. With renewable energy on everyone's lips at the moment I'm sure they will do very well for themselves. TheHeatingWarehouse.co.uk is a sister site of aquatech specifically targeting the UK market. This site isn't live just yet but should be launched in the next few days. The PolarBear.ie brochure site is a nice little springboard site to links to both of these new stores.

Over the coming weeks we have loads of new and exciting sites launching including a new online clothing store for Clintons, a new online wine store for Vanilla Grape Wines, the new redesigned City Gate Mahon and much more. My blog has suffered a bit due to two massive projects that I am currently working on. I'll have more details on this work closer to launch but I've been learning loads about Google Maps and highly scalable server setups as a result of these projects. Fun times :D

How to use a JQuery UI modal box with asp.net

View Demo | Download Source

I was recently asked to look into making a JQuery UI dialog box (aka a modal box) work with asp.net. I thought it would be straight forward but as with anything in asp.net it turned out to be a little bit trickier than I had initially thought. Part of the problem was that I wanted to put the dialog box on an asp.net submit button and depending on the user's choice either submit the page or cancel the action.

Thankfully I stumbled across this great article over at DeviantPoint. It was pretty much exactly what I needed. However, for my example I needed to only show the dialog box if any of the checkboxes on the screen were not selected. In other words a normal postback would occur if every check was selected but if there were any checkboxes not selected the user would be asked to confirm their action.

If you take a look at my very basic demo page you will see exactly what I'm talking about. You will find all of the code within the source files I have posted for download but below is a brief overview of what is going on.

View Demo | Download Source

HTML used:


    
    
    

This is a top class widget. Features include...

Below are the required items for this product to function correctly:
Required Item 1 Required Item 2
Required Item 3 Required Item 4

Javascript used:


C# Codebehind:

if (!Page.IsPostBack)
        {
            //this line is used to hold the exact postback function call used by the asp.net button
            this.MsgBoxContinue.Value = Page.ClientScript.GetPostBackEventReference(AddToBasket, string.Empty);

            //ensure the postback message is blank on load
            PostBackMsgTest.Text = ""; 
        }

        if (Page.IsPostBack)
        {
            PostBackMsgTest.Text = "Content posted back successfully.";
        }

Hide a Repeater and it's header text when there are no items to display using C#

One of the annoying little things about the asp.net repeater is that if you have text in a <HeaderTemplate> this will be shown on screen even if the repeater is empty. Nine times out of ten you will actually want to hide the text and only show it if the repeater contains information. This can be done by doing the following:

First adjust your repeater so that on PreRender of the repeater you call some code from your code behind:


    
        

Header text inside my repeater

... show database values in here ...

Next on your code behind page put in the following to check if the repeater contains any values:

protected void MyRepeater_PreRender(object sender, System.EventArgs e)
{
   //check to see if the repeater contains any items and if not hide it
   if (MyRepeater.Items.Count == 0)
   {
      MyRepeater.Visible = false;
   }
}

Fire up your page and test the repeater with and without items inside it. You should notice that when the repeater is empty the header text is not displayed which is what we wanted to happen.

Oct27

Dragnet Systems launch a new online store for The Really Good Soap Company

the-really-good-soap-company-website

Dragnet Systems has just launched one of our newest online stores - thereallygoodsoapcompany.ie. This online store features a brand new fully featured Wholesaler section as well as all the existing functionality of our store software. This new section will let the website owners manage wholesalers, add specific wholesaler products and even control the pricing per wholesaler for shared products.

This site also contains a fully content managed news section and a fully integrated newsletter system. The site benefits from having some really nice, professionally done, product imaging. Some of these items look good enough to eat! Although I wouldn't recommend it ;)

I really like the design work our lead designer Rebecca managed to pull off on this site. It really is a gorgeous site to look at and go through. I'd like to wish all at The Really Good Soap Company the best going forward with their new store. As well as having a .ie domain site they have also registered thereallygoodsoapcompany.com to appeal to a wider market as they will ship worldwide. I'm sure they will have loads of orders over the next few weeks as the online Christmas shopping kicks off!

Kusadasi, Turkey Trip 09

Ephesus Turkey Holiday 2009

I'm just back from a weeklong trip in Kusadasi, Turkey. For anyone thinking about going to Turkey for a sun break I highly recommend it! Below are some top tips to help you get the most out of your stay while in Kusadasi.

Where we stayed:

We stayed at the Palmin Hotel in Kusadasi. This hotel had a great selection of food on offer, especially for vegetarians (I highly recommend the Chicken Fajitas). The staff was also very helpful and really pleasant to deal with. The main attraction in choosing this hotel for us was the pool. It's a really nice big size, has 2 slides and the waiters from the poolside bar give table service. This is supposed to be a 4 star hotel but there were a few short comings with it:

  • The food overpriced compared to the bars/restaurants in the main town area. This is especially true for drinks.
  • You will have the pleasure of a really crappy bed with covers that are too small to fit 2 people.
  • Paper thin walls - don't expect to get any sleep during the night as you will hear people in heels walking around their rooms, conversations taking place, etc all as if those other people are in your room! By far the worst thing about the hotel.

Things to do in Kusadasi:

While we were staying at the hotel we booked ourselves on some of the day trips that were organized by our holiday rep. We went on the 'Shop till you drop' shopping experience and the Ephesus half day trip. Ephesus was amazing and if you are in Kusadasi you owe it to yourself to make the trip to see these remarkable ruins. DO NOT SIGN UP TO DO THE SHOPPING TOUR!!! I cannot stress that enough. You will be brought to outlet stores about 30mins away from your hotel by bus but there are no real shopping bargains to be had. It was a complete was of €20 each to do this trip. Save your money for the markets that happen on Wednesday instead. The markets are huge and you're sure to find your ideal gift there.

Shopping in Kusadasi town centre is a great experience, even on days without the markets. There are literally hundreds of shops selling handbags, jewellery, DVD's, etc. All 100% genuinely fake of course ;) Be sure to have your wits about you when shopping because the shopkeepers will try their best to overcharge you. Haggle, haggle, haggle and once you've done that, haggle some more! Some shopkeepers can be quite rude and forceful. Just remember that if you leave their shop you will more than likely find the same items 3-4 shops down the road so never feel like you have to buy your item from anyone who is pushy.

If you are in Kusadasi you have to try and make it to one of the main beaches. We went to Ladies Beach a few days during our stay and it was fantastic. Plenty of sun loungers at reasonable prices, really great tasting beer (Efes) and loads of bars and restaurants to choose where to eat. Try and eat in Rosy's bar at least once. The waiters were really friendly in there and you never felt rushed while having your dinner. Plus they have free wifi.

Getting around Kusadasi:

Kusadasi has a fantastic public transport system called the Dolmus. The Dolmus is a small bus that can carry around 15 people. The best thing is that the bus runs every 30-60 seconds. I never had to wait more than 20 seconds to get a bus. These buses go all around the city and even drop you to the door of your hotel. They really make travelling around in Kusadasi a breeze. They cost 2 Turkish Lira to use and run from 7am right up to midnight.

Other bits of advice:

The last piece of advice I can give you is to avoid buying any food in the Airport on your way home. Unfortunately for us we found out the hard way. €5 for a can of coke and €7.50 for a small bread roll! It was really super expensive because they know you'll be hungry and that there is nowhere else for you to grab a bite to eat. If you can, try to buy a sandwich and drink in Kusadasi before you go to the airport.

Above is only my take on the trip but from speaking to a few people on the airplane and while on the day trips I get the impression everyone else was feeling the same about Kusadasi. It was a fantastic place to visit with great shopping and food. If you are looking to just relax and put the feet up for a few days you could do a lot worse than Turkey. Just don't expect to save any money while you stay in Kusadasi as it is very much a tourist city and has prices to match.

Oct03

How to check if your drop down list contains a specific value using C#

If you want to set the default value of a drop down list from a value being passed to you by a third party you should always include a check to ensure that your drop down contains the value so that you don't end up with some nasty compiler errors.

To keep things simple let's say I want to check if my drop down contains the value "MyValue". If it does I want to pre-select that option for the user. To do this I would use something like below:

if (MyDropDownList.Items.FindByValue("MyValue") != null)
{
    MyDropDownList.SelectedValue = "MyValue";
}

You can also search based on the text value of your drop down by using FindByText instead of FindByValue.

Sep24

jQuery UI date picker - how to set the start date of your second calendar

set the mindate of a second calendar using jquery ui

If you haven't already looked into using the jquery UI calendars, you really should! One of my latest projects, www.hertzflydrive.com, uses these calendars on the homepage. They are quick to setup and offer loads of options that make them very flexible for anyone looking to use date pickers on their forms.

One of the most common setups is to use two calendars to let users pick 'From - To' dates. Placing two textboxes and setting them up to use the calendars is easy (and for this post I am assuming you can at least do that much) but what if we only want our second calendar to only allow the user to select dates on or after the date entered in the first calendar?

Well the good news is that this is easy to do using a custom function that is called before the calendar is displayed to the end user. The script below shows the jQuery for setting up two calendars on your form and the custom function to ensure that the dates the end user selects on the second calendar are either after today's date or after the value entered in our 'From' calendar.

jQuery - save as calendar-config.js in a folder called scripts:

$().ready(function() {
    $('.pUpDate, .dOffDate').datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        beforeShow: customRange,
        dateFormat: 'dd-mm-yy',
        showOn: 'both',
        buttonImage: 'images/calendar-icon.gif',
        buttonImageOnly: true,
        buttonText: 'Show Date Picker'
    });
});
function customRange(a) {
    var b = new Date();
    var c = new Date(b.getFullYear(), b.getMonth(), b.getDate());
    if (a.id == 'DropoffDate') {
        if ($('.pUpDate').datepicker('getDate') != null) {
            c = $('.pUpDate').datepicker('getDate');
        }
    }
    return {
        minDate: c
    }
}

The custom range function above should be self explanatory. We pass in the id of the element we clicked on (i.e. which textbox we're currently in) and if that textbox is the drop-off textbox we want to set the min date to be the value entered in the Pick-up textbox, assuming it has a value.

HTML:


    date picker dual calendar example
     
    
    
    
    
    



    
    

    
    

To help you get started you can download a working example of this demo here - min date jquery demo.zip (67.37 kb). To view it in action head over to hertzflydrive.com.

Hertz and Aerlingus team up for new project HertzFlyDrive.com, designed and developed by Dragnet Systems

HertzFlyDrive.com - A new car rental site from Hertz and Aerlingus, designed and developed by Dragnet Systems

After many months of work I'm proud to announce my latest project HertzFlyDrive.com. This website was designed from the ground up provide Hertz with a more effective way to manage their car rental booking information and help speed up the booking process for end users.

This site has a lot of new features in it that I had great fun with including Linq to XML for the XML calls to Hertz, jQuery UI date pickers, a brand new jQuery expander made specifically for this project, contacting the database using JSON and jQuery, multiple languages, etc. The list of new tech on the site is nearly endless! I'm proud of the speed of the site compared to their older site considering all of the extras we have added to the forms. By comparison our new site loads roughly twice as fast as the older Hertz site.

It's not only raw speed that helps the end user experience but also the ease of use of the site. We rose to the challenge and set about making the site a breeze to use for users. Our new car selection page actually combines two processes in one. On the old site the end user was required to go through to two separate pages for booking a car and picking the accessories that they might want. On our site this is all done on the same page. We have also included a very nice clean way for the user to upgrade their car choice without forcing them to go back a page and forward again. Steps like these all help speed up the booking process for end users and provide a much smoother experience.

It's in the admin tools that we've really gone to town with features. There are loads of snazzy extras we've built into this system. With the old site that Hertz had there were no stats for bookings or facilities to update offers on their site. Our brand new admin tools let Hertz quickly and easily add/update/delete/order any offer for any country and/or language.

There is also a brand new email marketing tool built for this site that allows admins to send and track emails sent to customers. The emails sent can be stored and stats like number of opens, click throughs or completed bookings from an email message are all store in our system. Customers can opt out of the email marketing at any time and there is even an option for them to easily opt back in if they decide to change their mind later on.

Finally, we have provided Hertz with enough stats to keep them busy for years to come! Everything from 'how many child seats were bought?' to 'whats our most popular destination?' is available to the site admins.

We're hoping that this new web system will help drive more sales for Hertz and that end users find the site a joy to use. I'd love to hear what you think about the site so let me know in the comments below.

GardeningOnline.ie gets ready for launch!

GardeningOnline.ie gears up for launch

Dragnet Systems is pleased to announce a brand new online gardening store for Dunsland Garden Centre owned by T.V. gardening presenter (and upcoming author!) Peter Dowdall.

This site brings even more advanced features to our core online store software like Advanced Search features that allow products to be displayed by planting seasons or by colour as well as the relevant department and a really outstanding design made by our super wiz design genius Rebecca.

Right now we're putting the finishing touches to the site to make sure it looks perfect for launch. The site will be launching very soon so check back soon.

The site is now live so go on and check it out at www.gardeningonline.ie.

Sep10