About the Sample Scripts

Assuming you kept the default installation option to include the CountryHawk samples, the installation program will create a new virtual web directory called CountryHawkSamples for you located off your default web site.

To run these samples, enter http://localhost/CountryHawkSamples/index.htm into your web browser. You must have the IIS web service installed and running to execute the samples.

These samples are well documented and intended to serve as a tutorial. To get the maximum benefit out of these samples we recommend that you view their source code to read the detailed comments contained therein.

The following is an explanation of the included sample scripts:

ASP Samples using CountryHawk ActiveX/COM:

ch_index.asp: Index of available samples with a brief explanation of what each sample does. To get started with the samples, point your browser to this page after copying all samples to an ASP directory.

ch_basics.asp: Demonstrates how to create an instance of the component and retrieve the country code, country name, and IP address for the current site visitor.

ch_statsByCountry.asp: Demonstrates how to automatically track statistics and produce reports on hits per country. This features can be used to produce real-time stats for your web site or for batch processing of web site log files.

ch_statsByRegion.asp: Demonstrates how to automatically track statistics and produce reports on hits per region. You may define regions and assign countries to each region however you wish.

ch_initialize.asp: Demonstrates how to use the Initialize method to get country information for a specific IP address, rather than the IP of the current site visitor. You will also use this method if creating instances of the country object from programming languages other then ASP, such as Visual C++, Visual Basic and ColdFusion. This sample also demonstrates how to use the IsValidIP method.

ch_listbox.asp: Demonstrates how to use the GetSelectList method to display a list of countries for a user to choose from on a web form, with the user's country automatically selected by default.

ch_listbox_custom.asp: Demonstrates how to display a customized list of countries for a user to choose from on a web form by using the optional parameters to the GetSelectList method. It also demonstrates how you can call custom JavaScript functions on various events for the list box.

ch_codeLookup.asp: Demonstrates how to look up a country name associated with a given country code by using the CountryName method.

ch_convertIP.asp: Demonstrates how to convert an IP address from a string to a four-byte integer and vice-versa. This is very useful for reducing the space required to store IP addresses in a database.

ch_restricted.asp: Demonstrates how to use the IsRestricted method to detect visitors from countries that you do not wish to access your content.

ch_isinlist.asp: Demonstrates how to use the IsInLIst method to detect whether a visitor is coming from a country in a list you define programmatically.

ASP.NET Samples using CountryHawk .NET:

Note: Samples with file names ending in "_vb.aspx" are written in VB.NET, and samples ending in "_cs.aspx" are written in C#. The VB.NET and C# samples are identical except for the differences in syntax between the languages.

ch_index_vb.aspx / ch_index_cs.aspx: Index of available samples with a brief explanation of what each sample does. To get started with the .NET samples, point your browser to this page after copying all samples to an ASP.NET directory.

ch_basics_vb.aspx / ch_basics_cs.aspx: Demonstrates how to use the component to retrieve the country code, country name, and IP address for the current site visitor.

ch_statsByCountry_vb.aspx / ch_statsByCountry_cs.aspx: Demonstrates how to automatically track statistics and produce reports on hits per country. This features can be used to produce real-time stats for your web site or for batch processing of web site log files.

ch_statsByRegion_vb.aspx / ch_statsByRegion_cs.aspx: Demonstrates how to automatically track statistics and produce reports on hits per region. You may define regions and assign countries to each region however you wish.

ch_initialize_vb.aspx / ch_initialize_cs.aspx: Demonstrates how to get country information for a specific IP address, rather than the IP of the current site visitor. You will also use this method if using CountryHawk from languages other then ASP.NET, such as VB.NET, C#, and any other .NET language.

ch_listbox_vb.aspx / ch_listbox_cs.aspx: Demonstrates how to use the GetSelectList method to display a list of countries for a user to choose from on a web form, with the user's country automatically selected by default.

ch_listbox_custom_vb.aspx / ch_listbox_custom_vb.aspx: Demonstrates how to display a customized list of countries for a user to choose from on a web form by using the optional parameters to the GetSelectList method. It also demonstrates how you can call custom JavaScript functions on various events for the list box.

ch_convertIP_vb.aspx / ch_convertIP_cs.aspx: Demonstrates how to convert an IP address from a string to a four-byte integer and vice-versa. This is very useful for reducing the space required to store IP addresses in a database.

ch_restricted_vb.aspx / ch_restricted_cs.aspx: Demonstrates how to use the IsRestricted method to detect visitors from countries that you do not wish to access your content.

ch_isinlist_vb.aspx / ch_isinlist_cs.aspx: Demonstrates how to use the IsInLIst method to detect whether a visitor is coming from a country in a list you define programmatically.

ColdFusion (CF) samples:

ch_basics.cfm: Demonstrates how to obtain the visitor's country code, country name, and IP address from ColdFusion scripts. This sample also demonstrates how to use the GetSelectList method from ColdFusion. This sample uses the <CF_CountryHawk> custom tag.

ch_initialize.cfm: Demonstrates how to use the Initialize method from ColdFusion and the <CF_CountryHawk> custom tag to get country information for a specific IP address, rather than the IP of the current site visitor. This sample also demonstrates how to use the IsValidIP method from ColdFusion.

Note: In order to run the ColdFusion samples you must have Macromedia ColdFusion or ColdFusion MX installed along with the Microsoft IIS web service.

See Also:

Quick Start Guide

Installation Guide

Properties and Methods Guide

Using the CountryHawk component