IP2Currency: Microsoft ASP.Net 2.0 - C# Sample Code

The sample code below provide you an example on how to obtain the latest currency exchange rate and the homeland currency by visitor's IP address.


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IP2CurrencyWebService;

public partial class IP2CurrencyWebServiceSoapClient : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        this.Lookup();

    }
    private void Lookup()
    {
		IP2CurrencyWebService.IP2CurrencyWebService x_IP2Currency = new IP2CurrencyWebService.IP2CurrencyWebService();
		IP2CurrencyWebService.IP2CurrencyOutput oIP2Currency = new IP2CurrencyWebService.IP2CurrencyOutput();
		IP2CurrencyWebService.IP2CurrencyInput iIP2Currency = new IP2CurrencyWebService.IP2CurrencyInput();

        try
        {
			iIP2Currency.VISITORIP = this.txtVisitorIP.Text;
			iIP2Currency.FROMCURRENCYCODE = this.txtFromCurrencyCode.Text;
			iIP2Currency.TOCURRENCYCODE = this.txtToCurrencyCode.Text;
			iIP2Currency.FROMAMOUNT = this.txtFromAmount.Text;
			iIP2Currency.VISITORIP = this.txtVisitorIP.Text;
			iIP2Currency.LICENSE = this.txtLicense.Text;

			oIP2Currency = x_IP2Currency.IP2Currency(iIP2Currency);

			this.txtResult.Text = "FROMCURRENCYCODE:" + oIP2Currency.FROMCURRENCYCODE + "\n";
			this.txtResult.Text += "TOCURRENCYCODE:" + oIP2Currency.TOCURRENCYCODE + "\n";
			this.txtResult.Text += "TOCURRENCYSYMBOL:" + oIP2Currency.TOCURRENCYSYMBOL + "\n";
			this.txtResult.Text += "FROMAMOUNT:" + oIP2Currency.FROMAMOUNT + "\n";
			this.txtResult.Text += "TOAMOUNT:" + oIP2Currency.TOAMOUNT + "\n";
			this.txtResult.Text += "CONVERSIONRATE:" + oIP2Currency.CONVERSIONRATE + "\n";
			this.txtResult.Text += "TOCOUNTRYNAME:" + oIP2Currency.TOCOUNTRYNAME + "\n";
			this.txtResult.Text += "TOCOUNTRYCODE:" + oIP2Currency.TOCOUNTRYCODE + "\n";
			this.txtResult.Text += "CREDITSAVAILABLE:" + oIP2Currency.CREDITSAVAILABLE + "\n";
			this.txtResult.Text += "MESSAGE:" + oIP2Currency.MESSAGE + "\n";
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
    private void ClearScreen()
    {
		this.txtVisitorIP.Text = "";
		this.txtFromCurrencyCode.Text = "";
		this.txtToCurrencyCode.Text = "";
		this.txtFromAmount.Text = "";
		this.txtVisitorIP.Text = "";
		this.txtLicense.Text = "";
		this.txtResult.Text = "";
    }


    protected void btnClear_Click(object sender, EventArgs e)
    {
        this.ClearScreen();
    }
}

Download the source code
You need a license key for the solution. And, it is free and available at IP2Currency Free License