Thursday, December 11, 2008

Paypal country code dropdown select html

I recently needed to build a paypal dropdown country list to pass to a PAYPAL checkout form, it took me a while to find the permitted values and build an HTML select list so I have included it here for anyone who may find it useful! View the source of this page to get the html code for the select box!

Wednesday, October 15, 2008

Convert Object Array To Dataset

Bind an Object Array to a dataset using the following code.

Code Snippet

using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace BusinessObject.Util
{
///
/// Utility Class for Object Arrays.
///

public class ObjectArray
{
private Object[] _objectArray;

public ObjectArray(Object[] objectArray)
{
this._objectArray = objectArray;
}

public DataSet ToDataSet()
{
DataSet ds = new DataSet();

XmlSerializer xmlSerializer =
new XmlSerializer(_objectArray.GetType());
StringWriter writer = new StringWriter();
xmlSerializer.Serialize(writer, _objectArray);
StringReader reader =
new StringReader(writer.ToString());

ds.ReadXml(reader);
return ds;
}
}
}

How to use the code:

Person[] personList;

personList = Course.GetPersonList();

ObjectArray objectArray = new ObjectArray(personList);Create a DataSet and convert your ObjectArray to a DataSet using the method:

DataSet ds = new DataSet();
ds = objectArray.ToDataSet();

Reference Taken From
http://tom.gilki.org/programming/net/Utils/ObjectArrayDataSet/index.shtml

This entry was posted on February 21, 2007 at 9:44 am and is filed under .NET 1.1.

Thursday, September 11, 2008

Optimising Images for Web Using c#

Useful function to optimise images for web using c#

public void OptimizeImage(string lcFilename, decimal widthRequired)
{

System.Drawing.Image originalimg = System.Drawing.Image.FromFile(lcFilename);

decimal _percentNeeded;

_percentNeeded = Convert.ToDecimal(widthRequired) / originalimg.Width;

Int32 lnWidth = Convert.ToInt32(widthRequired);

Int32 lnHeight = Convert.ToInt32(originalimg.Height * _percentNeeded);

System.Drawing.Bitmap bmpOut = null;

System.Drawing.Bitmap loBMP = new System.Drawing.Bitmap(lcFilename);

System.Drawing.Imaging.ImageFormat loFormat = loBMP.RawFormat;

decimal lnRatio;

int lnNewWidth = 0;

int lnNewHeight = 0;



if (loBMP.Width > loBMP.Height)
{

lnRatio = (decimal)lnWidth / loBMP.Width;

lnNewWidth = lnWidth;

decimal lnTemp = loBMP.Height * lnRatio;

lnNewHeight = (int)lnTemp;

}

else
{

lnRatio = (decimal)lnHeight / loBMP.Height;

lnNewHeight = lnHeight;

decimal lnTemp = loBMP.Width * lnRatio;

lnNewWidth = (int)lnTemp;

}

bmpOut = new System.Drawing.Bitmap(lnNewWidth, lnNewHeight);

System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpOut);

g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

g.FillRectangle(System.Drawing.Brushes.White, 0, 0, lnNewWidth, lnNewHeight);

g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);

string _tmpFile = System.Configuration.ConfigurationManager.AppSettings["ContentLocationRoot"] + "tmp.jpg";

bmpOut.Save(_tmpFile, System.Drawing.Imaging.ImageFormat.Jpeg);

loBMP.Dispose();
originalimg.Dispose();

System.IO.File.Delete(lcFilename);

System.IO.File.Copy(_tmpFile, lcFilename);
System.IO.File.Delete(_tmpFile);

}

"Internet Explorer cannot display the webpage" error caused by ASP.NET file upload control

I recently encountered a problem with ASP.NET whilst using a file upload control. Initial thoughts were that it was related to the AJAX extensions I was using, however after a lot of playing about, i found adding the following line to the web.config file resolved the problem,



Basically the problem is caused by an ASP.NET limit of around 4MB for a file upload, the above setting tells ASP.NET to allow larger files to be attached / uploaded.

Hope this helps someone.

"Internet Explorer cannot display the webpage" error caused by ASP.NET file upload control

I recently encountered a problem with ASP.NET whilst using a file upload control. Initial thoughts were that it was related to the AJAX extensions I was using, however after a lot of playing about, i found adding the following line to the web.config file resolved the problem,



Basically the problem is caused by an ASP.NET limit of around 4MB for a file upload, the above setting tells ASP.NET to allow larger files to be attached / uploaded.

Hope this helps someone.

Friday, August 22, 2008

SQL Country List

I was looking today to create a lookup table in SQL Server to hold a list of countries.

The following SQL script will create a table in SQL Server and populate it with country values:


CREATE TABLE [tblCountryLookup] (
[country_id] [smallint] IDENTITY (1, 1) NOT NULL ,
[country_desc] [varchar] (250) COLLATE Latin1_General_CI_AS NOT NULL ,
[country_active] [bit] NOT NULL ,
CONSTRAINT [PK_tblCountryLookup] PRIMARY KEY CLUSTERED
(
[country_id]
) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Afghanistan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Albania',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Algeria',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Andorra',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Angola',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Anguilla',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Antarctica',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Antigua and Barbuda',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Argentina',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Armenia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Aruba',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ascension Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Australia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Austria',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Azerbaijan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bahamas',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bahrain',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bangladesh',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Barbados',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Belarus',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Belgium',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Belize',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Benin',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bermuda',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bhutan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bolivia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bophuthatswana',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bosnia-Herzegovina',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Botswana',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bouvet Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Brazil',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('British Indian Ocean',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('British Virgin Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Brunei Darussalam',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Bulgaria',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Burkina Faso',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Burundi',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cambodia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cameroon',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Canada',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cape Verde Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cayman Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Central Africa',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Chad',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Channel Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Chile',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('China, Peoples Republic',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Christmas Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cocos (Keeling) Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Colombia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Comoros Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Congo',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cook Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Costa Rica',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Croatia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cuba',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Cyprus',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Czech Republic',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Denmark',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Djibouti',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Dominica',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Dominican Republic',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Easter Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ecuador',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Egypt',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('El Salvador',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('England',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Equatorial Guinea',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Estonia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ethiopia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Falkland Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Faeroe Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Fiji',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Finland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('France',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('French Guyana',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('French Polynesia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Gabon',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Gambia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Georgia Republic',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Germany',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Gibraltar',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Greece',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Greenland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Grenada',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guadeloupe (French)',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guatemala',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guernsey Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guinea Bissau',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guinea',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Guyana',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Haiti',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Heard and McDonald Isls',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Honduras',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Hong Kong',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Hungary',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Iceland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('India',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Iran',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Iraq',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ireland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Isle of Man',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Israel',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Italy',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ivory Coast',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Jamaica',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Japan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Jersey Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Jordan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Kazakhstan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Kenya',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Kiribati',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Kuwait',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Laos',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Latvia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Lebanon',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Lesotho',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Liberia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Libya',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Liechtenstein',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Lithuania',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Luxembourg',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Macao',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Macedonia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Madagascar',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Malawi',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Malaysia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Maldives',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mali',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Malta',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Martinique (French)',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mauritania',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mauritius',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mayotte',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mexico',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Micronesia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Moldavia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Monaco',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mongolia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Montenegro',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Montserrat',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Morocco',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Mozambique',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Myanmar',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Namibia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Nauru',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Nepal',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Netherlands Antilles',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Netherlands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('New Caledonia (French)',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('New Zealand',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Nicaragua',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Niger',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Niue',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Norfolk Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('North Korea',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Northern Ireland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Norway',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Oman',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Pakistan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Panama',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Papua New Guinea',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Paraguay',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Peru',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Philippines',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Pitcairn Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Poland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Polynesia (French)',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Portugal',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Qatar',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Reunion Island',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Romania',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Russia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Rwanda',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('S.Georgia Sandwich Isls',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Sao Tome, Principe',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('San Marino',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Saudi Arabia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Scotland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Senegal',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Serbia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Seychelles',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Shetland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Sierra Leone',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Singapore',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Slovak Republic',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Slovenia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Solomon Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Somalia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('South Africa',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('South Korea',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Spain',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Sri Lanka',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Helena',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Lucia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Pierre Miquelon',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Martins',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Kitts Nevis Anguilla',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('St. Vincent Grenadines',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Sudan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Suriname',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Svalbard Jan Mayen',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Swaziland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Sweden',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Switzerland',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Syria',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tajikistan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Taiwan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tahiti',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tanzania',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Thailand',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Togo',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tokelau',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tonga',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Trinidad and Tobago',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tunisia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Turkmenistan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Turks and Caicos Isls',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Tuvalu',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Uganda',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Ukraine',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('United Arab Emirates',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('United States',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Uruguay',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Uzbekistan',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Vanuatu',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Vatican City State',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Venezuela',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Vietnam',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Virgin Islands (Brit)',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Wales',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Wallis Futuna Islands',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Western Sahara',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Western Samoa',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Yemen',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Yugoslavia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Zaire',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Zambia',1);
INSERT INTO tblCountryLookup(country_desc,country_active) VALUES ('Zimbabwe',1);

Tuesday, August 19, 2008

Getting the URL path without the page filename in ASP.NET & C#

I needed to get the URL path of the current page object in ASP.NET and c# today, but without the filename part - e.g. myfile.aspx.

After a long hunt on the net re this, I found it was as simple as follows;

string pagePath = Page.TemplateSourceDirectory;

Hopefully this post will save someone else a long search!

Stripping HTML Code / Tags in C#

I needed a function today to take a string of HTML code and to return only the embedded text, i.e. to remove all html code.
As such I knocked up a simple function using regular expressions in C# - I have added this code below, it may be of use to someone.

Please note: You will need to import the system.text.regularexpressions namespace for this to work.

Here is the function:

private string stripHTML(string inputHTML)
{
inputHTML = inputHTML.Trim();
string toReturn = Regex.Replace(inputHTML, @"<(.\n)*?>", string.Empty);
return toReturn;
}

Friday, August 15, 2008

Welcome to my Web Design and Development Blog


Welcome to my new web design and development Blog. The purpose of this blog is to share with fellow web designers and developers my experiences whilst building and supporting web sites and web-based applications.

I will also be sharing useful code snippets via this blog.

Having worked with the internet for 12 years, I have seen many changes in the industry. I remember working with early versions of Dreamweaver and ASP v1.0 when it was first released by Microsoft and thinking it was cutting edge.

Websites today have come along way, the advancement of technologies, ASP.NET, JAVA, PHP and AJAX to name just a few, gives web developers power to their arm to develop much more than just static, brochure websites.

Of all of the websites I work on - either working direct for clients or on sub-contract work, almost all now require dynamic functionality such as shopping carts, content management systems, blogs or calculators. With all of this extra functionality coming on board, we are increasingly demanding more powerful servers, more bandwidth and general computing power. Search engine optimisation is also becoming more and more difficult with more businesses than ever competing for that first-page placement on search engines.

What the future will hold for the internet is still to be seen, there is talk of The Grid as a possible replacement, we shall see!