Book a taxi online using GlobalTaxiNetworks.com

GlobalTaxiNetworks.com has finally launched! Now any business can book a taxi, know how much it's going to cost in advance, save favourite journeys, re-book previous journey's, add via routes and even print off invoices all in the click of a button....ok it's a few clicks but it's still a slick system if I say so myself :D

Using the power of Google maps with help from jQuery, C# and Linq to SQL we're able to work out rates for your journey anywhere in Ireland. This system has been built with multiple markets in mind and we're hoping to help roll out the system for Tiománaí Services Ltd (the site system owners) into the UK, western Europe and further over the next 12months.

Initially when I started building the system I wasn't sure if it could be done but from trial and error - and countless late nights! - the site is finally up and running. I have to say that it's been one of the best projects I've worked on while at Dragnet Systems. It's also one of the first systems powered by our newest admin tool technology. The owners of this new system can look after any aspect of this complex system with ease. Everything from approving users who sign up, setting pricing and saving locations on Google maps can all be easily added/updated/deleted in a matter of seconds. As with everything we develop we have ensures that the admin tools get as much love as the front end of the website itself.

I'm really excited by the possibilities this site brings to the market and I'd like to wish everyone in Tiománaí Services Ltd all the best with the site going forward!

Tags: , ,

Dragnet Systems launches VGWines.com

Vanilla Grape Wines goes live using dragnet systems online store software

It's a new year and thankfully the work inside in Dragnet Systems shows no signs of slowing down. VGWines.com is a brand new online store for an existing wine retailer based in Kerry, Vanilla Grape Wines Ltd.

The store uses Dragnet Systems own online store software. We have rebuilt the front end engine to make it easier for our in-house designers to build templates for any new stores going forward. It will also help increase the speed at which we can build new stores for clients now which is fantastic news.

It was interesting to note that due to legal issues with selling alcohol online VGWines.com can only sell to Irish consumers. This is the first time one of our stores has been faced with such a restriction but it makes sense. As always Rebecca has done a fantastic job with the design of the site and it definitely has a perfect 'wine' mood about it. I'm getting thirsty just looking at it :)

Tags: , , ,

How to read from and write to the web.config file using C#

To read from a Web.Config file using C# is very easy to do. Let's say we have an appSettings tag in our Web.Config that holds the website title. Inside in our web.config you would have something like this:


   

To get .net to read this value all you need to do is add this to your code behind page on your site. Be sure to add the System.Web.Configuration namespace as this is not added by default.

using System.Web.Configuration;

//read in the SiteName tag from web.config
string MySiteName = WebConfigurationManager.AppSettings["SiteName"];
If you want more details on how to read from web.config please see my earlier post here

You might also want to write to your web.config file to allow the end user to update this data. To do this you must ensure that the Network Service user (or the ASP.NET user on WinServer 03 or earlier) has modify permissions on your website root folder.

Without the correct permission you will get the following error if you try to add the code below:
An error occurred loading a configuration file: Access to the path 'c:\inetpub\wwwroot\yourwebsitefolder\py39wsfg.tmp' is denied.

Assuming you have setup the correct permissions this code below will allow your web app to write to the web.config file.

//update the SiteName tag in web.config with a new value
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
config.AppSettings.Settings["SiteName"].Value = "New Site Name Value";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");

Tags: ,

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.";
        }

Tags: , ,

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.

Tags: ,

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.

Tags: ,

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.

Tags: , , , ,

how to sort a DataTable by a specific column using C#

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: ,

How to get the values of HTML checkboxes within a Repeater using C#

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: ,

Solution to storing lots of form information between pages - Use a Dictionary Object and store it into a Session

I am working on a site at the moment that requires me to store a lot of user entered values from form elements from one page to the next before a user can complete an order. This is unusual as normally the user just enters all the required values on one screen but for this particular project the design required the project to be setup to work like this.

ViewStates or hidden fields are a nice way to store form values on post back but it's very hard to carry those values across to other pages. The Session object was my only choice.

I currently use the asp.net session state service for all my projects. This is a little slower (around 10%-15%) than using the default session setup of in-proc but it has the advantage that the sessions themselves are a lot more stable and tend to last the right amount of time I set them to before they expire.

The main issue I had with the design was that it is a high volume site and that the number one requirement was that this new site was quick to use. I had around 15 values that needed to be carried through the site after page one and around 5 more items to be gathered from pages 2 and 3 before sending the values off to a third party through XML. A database table would have worked except that it would have been slower than using a session and I had some values that were in dynamic Lists which would made it trickier to save into a table.

I did some research and found that List objects are great but slow down if you store a lot of information in them so I decided to use a Dictionary object to hold the user values. I would then store this object into a Session to hold my values from page to page.

It's quiet easy to setup a Dictionary object to hold these user values. First thing you need to do is setup the object. Once you've done that you can add new items to it very easily. Once you have stored all your items into your Dictionary object, simply store it in a session.

To get your values out of your session all you have to do is:

Although this isn't ideal, because of the current site setup I wasn't left with much of a choice but to go down this route. The downside to storing my values in a Dictionary object in a session using the State service is that every time I pull the item out of the session or store it to the session there is an overhead as .net serializes my data. It's a small price to pay though. On the plus side I have a setup that allows me to store a lot of variables but just use one session value to hold them.

This particular project is on a brand new Win Server 2008 with buckets of memory and so far, thankfully, the site has worked and scaled up quite well for us.

Tags: ,