Tags: , , , , | Categories: C#, General Posted by RichardReddy on 9/24/2009 11:55 AM | Comments (0)

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.

Tags: , , , , , , | Categories: General, jQuery, Online Stores Posted by RichardReddy on 9/23/2009 7:26 AM | Comments (2)
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.

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 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.

Tags: , , , | Categories: C#, General Posted by RichardReddy on 9/9/2009 2:51 PM | Comments (0)

The majority of the time when displaying content to the end user you will want to order the data by certain criteria. More often than not you will want to sort by a specific column. If your data is in a DataTable how do you do that?

You need to convert your DataTable into a DataView, apply your sort and save the results back to your DataTable. Let's say we have a DataTable that holds details of all our customers and we want to order the information by their names. To keep things simple I will hard code in only 2 customer values here. You would order the information by doing the following:

using System.Data;

//create our datatable and setup with 2 columns
DataTable dt = new DataTable();
dt.Columns.Add("CustomerFirstname", typeof(string));
dt.Columns.Add("CustomerSurname", typeof(string));
DataRow dr;

//store some values into datatable
//just using 2 names as example
dr = dt.NewRow();
dr["CustomerFirstname"] = "John";
dr["CustomerSurname"] = "Murphy";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["CustomerFirstname"] = "John";
dr["CustomerSurname"] = "Doe";
dt.Rows.Add(dr);

//check to make sure our datatable has at
//least one value. For this example it's not
//really need but if we were taking the 
//values from a database then this would be
//very important!
if (dt.Rows.Count > 0)
{
   //convert DataTable to DataView
   DataView dv = dt.DefaultView;
   //apply the sort on CustomerSurname column
   dv.Sort = "CustomerSurname";
   //save our newly ordered results back into our datatable
   dt = dv.ToTable();
}

//display your datatable to the user by databinding
//to repeater/gridview
Tags: , , | Categories: C#, General Posted by RichardReddy on 9/7/2009 12:02 PM | Comments (0)

If you want to read in a bunch of HTML checkboxes that are in a repeater using C# then you need to add a runat="server" element to you checkbox input tag. For example:

In your code behind you can now read in this element by using the following code:

using System.Web.UI.HtmlControls;

foreach (RepeaterItem currentControl in MyRepaterList.Items)
{
   HtmlInputCheckBox MyCheckBox = new HtmlInputCheckBox();
   MyCheckBox = (HtmlInputCheckBox)currentControl.FindControl("CheckboxName");
   if (MyCheckBox.Checked)
   {
      //logic if checkbox is ticked here
   }
}

The above code will loop through all the HTML checkbox elements within your repeater. You can easily modify this to let you look for HTML textboxes (HtmlInputText), HTML radio buttons (HtmlInputRadioButton), etc.

Tags: , , , | Posted by richardreddy on 9/2/2009 7:04 PM | Comments (21)

[Feb 24 2010 Update]

I just wanted to update this post to help keep it fresh. If you head over to CodePlex there is a download pack containing every existing theme for BlogEngine...well that's what they say but I know of a few that it's missing. Still, it's handy to have over 90% of the themes in the one download. I have also cleaned up the list below as some of the links were dead. If anyone has any new sites with more than 1 theme on them please let me know and I will update the list below.

[Original Post]

Since I started using BlogEngine.net I noticed that the one thing everyone complains about is that the themes are hard to find. I'd have to agree. There are theme sites out there but for some reason they're a little tricky to find.

Below is a list of the current BlogEngine theme sites I have found. These links aren't in any order. I'm also fairly confident that there are tons more sites out there with themes so feel free to add them to the comments and I'll update the list.

blogenginetheme.com - This is one of the larger theme collection sites out there for BlogEngine. The site promotes theme authors to upgrade their themes to be BE 1.5+ compatible by offering to place them on the first page of results if they do. This is a great idea to get some of the better BE 1.3/1.4 themes updated for use on the newer BlogEngine codebase.

onesoft.dk - some fantastic themes here and this is actually where I downloaded my first theme from. Unfortunately the site isn't updated as much as it was in the past but there are still some really nice themes to be found here. Mainly BE 1.3/1.4 themes here.

jankoatwarpspeed.com - This is one of my favourite website to visit. Janko is an ASP.NET guy like most of us (or at least I'm assuming you are because you use blogengine.net!) and regularly has great posts on .net and jquery that you might find interesting. As for themes he has a small collection (compared to the above list) but there are some nice themes here. You might find that you click through for the themes but stay for the content!

mooglegiant.net - There is a small collection of themes on this site. The themes are fairly basic in structure but sometimes that can be exactly what you need. I'm adding here because these themes can be easy and quick to modify and adjust. When you just want to knock out a blog for a client and need just a simple theme, one of these could hit the spot.

rtur.net - A small selection of themes (by which I mean 2) on this site but the developer keeps them up to date for BE 1.5.

geekiest.net - This blogger has a few blogengine themes up on his site. Many of the themes use designs from open source design sites but the list is always growing.

Obviously there is of course the BlogEngine.net site itself which has a large collection of themes on it's theme page and over at the unofficial forum. Most of the themes on those links appear to be older themes for BE 1.3/1.4.

Finally, if you're looking to get stuck in and making your own theme you can read a quick how to over at Al Nyveldt's blog. The screencast is targeted at slightly older versions of BE but the process is pretty much the same for 1.5. He is one of the main developers of BlogEngine and his site has tons of tips and tricks to get the most out of BlogEngine.

If you have any suggestions for some great theme sites out there for BlogEngine let me know and I'll be sure to include them on the list.