Current Currency Rate in Your Website

Current Currency Rate in Your Website

 
Do you want the current currency rates embedded in your webpage? Here is the tutorial.
 
Here I am using a webservice again.
 
Open this link webservice
 
Now, before using it, ensure it's running properly, then scroll down and click the function "ConversionRate".
 
Curency convertor
 
Now enter the parameters and click the "Invoke" button.
 
Invoke web service
 
Finally, you will get the current rate in a new window, as in the following:
 
Current Curency Rate
 
Fine, it's working.
 
Well, now let's embed this into a webpage.
 
First of all, add the reference for this webservice to your website.
  1. Create a new website
  2. Open Solution Explorer, select your website and right-click and select "Add Web Reference"
  3. Now the following window will be opened, enter http://www.webservicex.net/CurrencyConvertor.asmx?WSDL as the URL, press Enter and change the web reference name (it's optional, I changed it to "myservice"), and click the "Add Reference" button (circled in the image)
Web Reference
 
Now enter the following code in the Default.aspx file. I put the country's names in the dropdownlist and put their codes in the value property (country codes are copied from the given webservice).
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="~/Default.aspx.cs" Inherits="_Default" %>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4.   
  5.      <head id="Head1" runat="server">  
  6.           <title></title>  
  7.      </head>  
  8.   
  9.      <body>  
  10.           <form id="form1" runat="server">  
  11.                <div>  
  12.                     Enter Amount           
  13.                     <asp:TextBox ID="txtAmt" runat="server" Width="205px"></asp:TextBox>  
  14.                     <br />  
  15.                     <br />  
  16.                     <br />  
  17.                     From  
  18.                     <asp:DropDownList ID="drpFrom" runat="server">  
  19.                          <asp:ListItem Value="AFA">Afghanistan Afghani</asp:ListItem>  
  20.                          <asp:ListItem Value="AUD">Australian Dollar</asp:ListItem>  
  21.                          <asp:ListItem Value="AFA">Afghanistan Afghani</asp:ListItem>  
  22.                          <asp:ListItem Value="ALL">Albanian Lek</asp:ListItem>  
  23.                          <asp:ListItem Value="DZD">Algerian Dinar</asp:ListItem>  
  24.                          <asp:ListItem Value="ARS">Argentine Peso</asp:ListItem>  
  25.                          <asp:ListItem Value="AWG">Aruba Florin</asp:ListItem>  
  26.                          <asp:ListItem Value="AUD">Australian Dollar</asp:ListItem>  
  27.                          <asp:ListItem Value="BSD">Bahamian Dollar</asp:ListItem>  
  28.                          <asp:ListItem Value="BHD">Bahraini Dinar</asp:ListItem>  
  29.                          <asp:ListItem Value="BDT">Bangladesh Taka</asp:ListItem>  
  30.                          <asp:ListItem Value="BBD">Barbados Dollar</asp:ListItem>  
  31.                          <asp:ListItem Value="BZD">Belize Dollar</asp:ListItem>  
  32.                          <asp:ListItem Value="BMD">Bermuda Dollar</asp:ListItem>  
  33.                          <asp:ListItem Value="BTN">Bhutan Ngultrum</asp:ListItem>  
  34.                          <asp:ListItem Value="BOB">Bolivian Boliviano</asp:ListItem>  
  35.                          <asp:ListItem Value="BWP">Botswana Pula</asp:ListItem>  
  36.                          <asp:ListItem Value="BRL">Brazilian Real</asp:ListItem>  
  37.                          <asp:ListItem Value="GBP">British Pound</asp:ListItem>  
  38.                          <asp:ListItem Value="BND">Brunei Dollar</asp:ListItem>  
  39.                          <asp:ListItem Value="BIF">Burundi Franc</asp:ListItem>  
  40.                          <asp:ListItem Value="XOF">CFA Franc (BCEAO)</asp:ListItem>  
  41.                          <asp:ListItem Value="XAF">CFA Franc (BEAC)</asp:ListItem>  
  42.                          <asp:ListItem Value="KHR">Cambodia Riel</asp:ListItem>  
  43.                          <asp:ListItem Value="CAD">Canadian Dollar</asp:ListItem>  
  44.                          <asp:ListItem Value="CVE">Cape Verde Escudo</asp:ListItem>  
  45.                          <asp:ListItem Value="KYD">Cayman Islands Dollar</asp:ListItem>  
  46.                          <asp:ListItem Value="CLP">Chilean Peso</asp:ListItem>  
  47.                          <asp:ListItem Value="CNY">Chinese Yuan</asp:ListItem>  
  48.                          <asp:ListItem Value="COP">Colombian Peso</asp:ListItem>  
  49.                          <asp:ListItem Value="KMF">Comoros Franc</asp:ListItem>  
  50.                          <asp:ListItem Value="CRC">Costa Rica Colon</asp:ListItem>  
  51.                          <asp:ListItem Value="HRK">Croatian Kuna</asp:ListItem>  
  52.                          <asp:ListItem Value="CUP">Cuban Peso</asp:ListItem>  
  53.                          <asp:ListItem Value="CYP">Cyprus Pound</asp:ListItem>  
  54.                          <asp:ListItem Value="CZK">Czech Koruna</asp:ListItem>  
  55.                          <asp:ListItem Value="DKK">Danish Krone</asp:ListItem>  
  56.                          <asp:ListItem Value="DJF">Dijibouti Franc</asp:ListItem>  
  57.                          <asp:ListItem Value="DOP">Dominican Peso</asp:ListItem>  
  58.                          <asp:ListItem Value="XCD">East Caribbean Dollar</asp:ListItem>  
  59.                          <asp:ListItem Value="EGP">Egyptian Pound</asp:ListItem>  
  60.                          <asp:ListItem Value="SVC">El Salvador Colon</asp:ListItem>  
  61.                          <asp:ListItem Value="EEK">Estonian Kroon</asp:ListItem>  
  62.                          <asp:ListItem Value="ETB">Ethiopian Birr</asp:ListItem>  
  63.                          <asp:ListItem Value="EUR">Euro</asp:ListItem>  
  64.                          <asp:ListItem Value="FKP">Falkland Islands Pound</asp:ListItem>  
  65.                          <asp:ListItem Value="GMD">Gambian Dalasi</asp:ListItem>  
  66.                          <asp:ListItem Value="GHC">Ghanian Cedi</asp:ListItem>  
  67.                          <asp:ListItem Value="GIP">Gibraltar Pound</asp:ListItem>  
  68.                          <asp:ListItem Value="XAU">Gold Ounces</asp:ListItem>  
  69.                          <asp:ListItem Value="GTQ">Guatemala Quetzal</asp:ListItem>  
  70.                          <asp:ListItem Value="GNF">Guinea Franc</asp:ListItem>  
  71.                          <asp:ListItem Value="GYD">Guyana Dollar</asp:ListItem>  
  72.                          <asp:ListItem Value="HTG">Haiti Gourde</asp:ListItem>  
  73.                          <asp:ListItem Value="HNL">Honduras Lempira</asp:ListItem>  
  74.                          <asp:ListItem Value="HKD">Hong Kong Dollar</asp:ListItem>  
  75.                          <asp:ListItem Value="HUF">Hungarian Forint</asp:ListItem>  
  76.                          <asp:ListItem Value="ISK">Iceland Krona</asp:ListItem>  
  77.                          <asp:ListItem Value="INR">Indian Rupee</asp:ListItem>  
  78.                          <asp:ListItem Value="IDR">Indonesian Rupiah</asp:ListItem>  
  79.                          <asp:ListItem Value="IQD">Iraqi Dinar</asp:ListItem>  
  80.                          <asp:ListItem Value="ILS">Israeli Shekel</asp:ListItem>  
  81.                          <asp:ListItem Value="JMD">Jamaican Dollar</asp:ListItem>  
  82.                          <asp:ListItem Value="JPY">Japanese Yen</asp:ListItem>  
  83.                          <asp:ListItem Value="JOD">Jordanian Dinar</asp:ListItem>  
  84.                          <asp:ListItem Value="KZT">Kazakhstan Tenge</asp:ListItem>  
  85.                          <asp:ListItem Value="KES">Kenyan Shilling</asp:ListItem>  
  86.                          <asp:ListItem Value="KRW">Korean Won</asp:ListItem>  
  87.                          <asp:ListItem Value="KWD">Kuwaiti Dinar</asp:ListItem>  
  88.                          <asp:ListItem Value="LAK">Lao Kip</asp:ListItem>  
  89.                          <asp:ListItem Value="LVL">Latvian Lat</asp:ListItem>  
  90.                          <asp:ListItem Value="LBP">Lebanese Pound</asp:ListItem>  
  91.                          <asp:ListItem Value="LSL">Lesotho Loti</asp:ListItem>  
  92.                          <asp:ListItem Value="LRD">Liberian Dollar</asp:ListItem>  
  93.                          <asp:ListItem Value="LYD">Libyan Dinar</asp:ListItem>  
  94.                          <asp:ListItem Value="LTL">Lithuanian Lita</asp:ListItem>  
  95.                          <asp:ListItem Value="MOP">Macau Pataca</asp:ListItem>  
  96.                          <asp:ListItem Value="MKD">Macedonian Denar</asp:ListItem>  
  97.                          <asp:ListItem Value="MGF">Malagasy Franc</asp:ListItem>  
  98.                          <asp:ListItem Value="MWK">Malawi Kwacha</asp:ListItem>  
  99.                          <asp:ListItem Value="MYR">Malaysian Ringgit</asp:ListItem>  
  100.                          <asp:ListItem Value="MVR">Maldives Rufiyaa</asp:ListItem>  
  101.                          <asp:ListItem Value="MTL">Maltese Lira</asp:ListItem>  
  102.                          <asp:ListItem Value="MRO">Mauritania Ougulya</asp:ListItem>  
  103.                          <asp:ListItem Value="MUR">Mauritius Rupee</asp:ListItem>  
  104.                          <asp:ListItem Value="MXN">Mexican Peso</asp:ListItem>  
  105.                          <asp:ListItem Value="MDL">Moldovan Leu</asp:ListItem>  
  106.                          <asp:ListItem Value="MNT">Mongolian Tugrik</asp:ListItem>  
  107.                          <asp:ListItem Value="MAD">Moroccan Dirham</asp:ListItem>  
  108.                          <asp:ListItem Value="MZM">Mozambique Metical</asp:ListItem>  
  109.                          <asp:ListItem Value="MMK">Myanmar Kyat</asp:ListItem>  
  110.                          <asp:ListItem Value="NAD">Namibian Dollar</asp:ListItem>  
  111.                          <asp:ListItem Value="NPR">Nepalese Rupee</asp:ListItem>  
  112.                          <asp:ListItem Value="ANG">Neth Antilles Guilder</asp:ListItem>  
  113.                          <asp:ListItem Value="NZD">New Zealand Dollar</asp:ListItem>  
  114.                          <asp:ListItem Value="NIO">Nicaragua Cordoba</asp:ListItem>  
  115.                          <asp:ListItem Value="NGN">Nigerian Naira</asp:ListItem>  
  116.                          <asp:ListItem Value="KPW">North Korean Won</asp:ListItem>  
  117.                          <asp:ListItem Value="NOK">Norwegian Krone</asp:ListItem>  
  118.                          <asp:ListItem Value="OMR">Omani Rial</asp:ListItem>  
  119.                          <asp:ListItem Value="XPF">Pacific Franc</asp:ListItem>  
  120.                          <asp:ListItem Value="PKR">Pakistani Rupee</asp:ListItem>  
  121.                          <asp:ListItem Value="XPD">Palladium Ounces</asp:ListItem>  
  122.                          <asp:ListItem Value="PAB">Panama Balboa</asp:ListItem>  
  123.                          <asp:ListItem Value="PGK">Papua New Guinea Kina</asp:ListItem>  
  124.                          <asp:ListItem Value="PYG">Paraguayan Guarani</asp:ListItem>  
  125.                          <asp:ListItem Value="PEN">Peruvian Nuevo Sol</asp:ListItem>  
  126.                          <asp:ListItem Value="PHP">Philippine Peso</asp:ListItem>  
  127.                          <asp:ListItem Value="XPT">Platinum Ounces</asp:ListItem>  
  128.                          <asp:ListItem Value="PLN">Polish Zloty</asp:ListItem>  
  129.                          <asp:ListItem Value="QAR">Qatar Rial</asp:ListItem>  
  130.                          <asp:ListItem Value="ROL">Romanian Leu</asp:ListItem>  
  131.                          <asp:ListItem Value="RUB">Russian Rouble</asp:ListItem>  
  132.                          <asp:ListItem Value="WST">Samoa Tala</asp:ListItem>  
  133.                          <asp:ListItem Value="STD">Sao Tome Dobra</asp:ListItem>  
  134.                          <asp:ListItem Value="SAR">Saudi Arabian Riyal</asp:ListItem>  
  135.                          <asp:ListItem Value="SCR">Seychelles Rupee</asp:ListItem>  
  136.                          <asp:ListItem Value="SLL">Sierra Leone Leone</asp:ListItem>  
  137.                          <asp:ListItem Value="XAG">Silver Ounces</asp:ListItem>  
  138.                          <asp:ListItem Value="SGD">Singapore Dollar</asp:ListItem>  
  139.                          <asp:ListItem Value="SKK">Slovak Koruna</asp:ListItem>  
  140.                          <asp:ListItem Value="SIT">Slovenian Tolar</asp:ListItem>  
  141.                          <asp:ListItem Value="SBD">Solomon Islands Dollar</asp:ListItem>  
  142.                          <asp:ListItem Value="SOS">Somali Shilling</asp:ListItem>  
  143.                          <asp:ListItem Value="ZAR">South African Rand</asp:ListItem>  
  144.                          <asp:ListItem Value="LKR">Sri Lanka Rupee</asp:ListItem>  
  145.                          <asp:ListItem Value="SHP">St Helena Pound</asp:ListItem>  
  146.                          <asp:ListItem Value="SDD">Sudanese Dinar</asp:ListItem>  
  147.                          <asp:ListItem Value="SRG">Surinam Guilder</asp:ListItem>  
  148.                          <asp:ListItem Value="SZL">Swaziland Lilageni</asp:ListItem>  
  149.                          <asp:ListItem Value="SEK">Swedish Krona</asp:ListItem>  
  150.                          <asp:ListItem Value="TRY">Turkey Lira</asp:ListItem>  
  151.                          <asp:ListItem Value="CHF">Swiss Franc</asp:ListItem>  
  152.                          <asp:ListItem Value="SYP">Syrian Pound</asp:ListItem>  
  153.                          <asp:ListItem Value="TWD">Taiwan Dollar</asp:ListItem>  
  154.                          <asp:ListItem Value="TZS">Tanzanian Shilling</asp:ListItem>  
  155.                          <asp:ListItem Value="THB">Thai Baht</asp:ListItem>  
  156.                          <asp:ListItem Value="TOP">Tonga Pa'anga</asp:ListItem>  
  157.                          <asp:ListItem Value="TTD">Trinidad&Tobago Dollar</asp:ListItem>  
  158.                          <asp:ListItem Value="TND">Tunisian Dinar</asp:ListItem>  
  159.                          <asp:ListItem Value="TRL">Turkish Lira</asp:ListItem>  
  160.                          <asp:ListItem Value="USD">U.S. Dollar</asp:ListItem>  
  161.                          <asp:ListItem Value="AED">UAE Dirham</asp:ListItem>  
  162.                          <asp:ListItem Value="UGX">Ugandan Shilling</asp:ListItem>  
  163.                          <asp:ListItem Value="UAH">Ukraine Hryvnia</asp:ListItem>  
  164.                          <asp:ListItem Value="UYU">Uruguayan New Peso</asp:ListItem>  
  165.                          <asp:ListItem Value="VUV">Vanuatu Vatu</asp:ListItem>  
  166.                          <asp:ListItem Value="VEB">Venezuelan Bolivar</asp:ListItem>  
  167.                          <asp:ListItem Value="VND">Vietnam Dong</asp:ListItem>  
  168.                          <asp:ListItem Value="YER">Yemen Riyal</asp:ListItem>  
  169.                          <asp:ListItem Value="YUM">Yugoslav Dinar</asp:ListItem>  
  170.                          <asp:ListItem Value="ZMK">Zambian Kwacha</asp:ListItem>  
  171.                          <asp:ListItem Value="ZWD">Zimbabwe Dollar</asp:ListItem>  
  172.                     </asp:DropDownList>  
  173.                         To     
  174.                     <asp:DropDownList ID="drpTo" runat="server">  
  175.                          <asp:ListItem Value="AFA">Afghanistan Afghani</asp:ListItem>  
  176.                          <asp:ListItem Value="AUD">Australian Dollar</asp:ListItem>  
  177.                          <asp:ListItem Value="AFA">Afghanistan Afghani</asp:ListItem>  
  178.                          <asp:ListItem Value="ALL">Albanian Lek</asp:ListItem>  
  179.                          <asp:ListItem Value="DZD">Algerian Dinar</asp:ListItem>  
  180.                          <asp:ListItem Value="ARS">Argentine Peso</asp:ListItem>  
  181.                          <asp:ListItem Value="AWG">Aruba Florin</asp:ListItem>  
  182.                          <asp:ListItem Value="AUD">Australian Dollar</asp:ListItem>  
  183.                          <asp:ListItem Value="BSD">Bahamian Dollar</asp:ListItem>  
  184.                          <asp:ListItem Value="BHD">Bahraini Dinar</asp:ListItem>  
  185.                          <asp:ListItem Value="BDT">Bangladesh Taka</asp:ListItem>  
  186.                          <asp:ListItem Value="BBD">Barbados Dollar</asp:ListItem>  
  187.                          <asp:ListItem Value="BZD">Belize Dollar</asp:ListItem>  
  188.                          <asp:ListItem Value="BMD">Bermuda Dollar</asp:ListItem>  
  189.                          <asp:ListItem Value="BTN">Bhutan Ngultrum</asp:ListItem>  
  190.                          <asp:ListItem Value="BOB">Bolivian Boliviano</asp:ListItem>  
  191.                          <asp:ListItem Value="BWP">Botswana Pula</asp:ListItem>  
  192.                          <asp:ListItem Value="BRL">Brazilian Real</asp:ListItem>  
  193.                          <asp:ListItem Value="GBP">British Pound</asp:ListItem>  
  194.                          <asp:ListItem Value="BND">Brunei Dollar</asp:ListItem>  
  195.                          <asp:ListItem Value="BIF">Burundi Franc</asp:ListItem>  
  196.                          <asp:ListItem Value="XOF">CFA Franc (BCEAO)</asp:ListItem>  
  197.                          <asp:ListItem Value="XAF">CFA Franc (BEAC)</asp:ListItem>  
  198.                          <asp:ListItem Value="KHR">Cambodia Riel</asp:ListItem>  
  199.                          <asp:ListItem Value="CAD">Canadian Dollar</asp:ListItem>  
  200.                          <asp:ListItem Value="CVE">Cape Verde Escudo</asp:ListItem>  
  201.                          <asp:ListItem Value="KYD">Cayman Islands Dollar</asp:ListItem>  
  202.                          <asp:ListItem Value="CLP">Chilean Peso</asp:ListItem>  
  203.                          <asp:ListItem Value="CNY">Chinese Yuan</asp:ListItem>  
  204.                          <asp:ListItem Value="COP">Colombian Peso</asp:ListItem>  
  205.                          <asp:ListItem Value="KMF">Comoros Franc</asp:ListItem>  
  206.                          <asp:ListItem Value="CRC">Costa Rica Colon</asp:ListItem>  
  207.                          <asp:ListItem Value="HRK">Croatian Kuna</asp:ListItem>  
  208.                          <asp:ListItem Value="CUP">Cuban Peso</asp:ListItem>  
  209.                          <asp:ListItem Value="CYP">Cyprus Pound</asp:ListItem>  
  210.                          <asp:ListItem Value="CZK">Czech Koruna</asp:ListItem>  
  211.                          <asp:ListItem Value="DKK">Danish Krone</asp:ListItem>  
  212.                          <asp:ListItem Value="DJF">Dijibouti Franc</asp:ListItem>  
  213.                          <asp:ListItem Value="DOP">Dominican Peso</asp:ListItem>  
  214.                          <asp:ListItem Value="XCD">East Caribbean Dollar</asp:ListItem>  
  215.                          <asp:ListItem Value="EGP">Egyptian Pound</asp:ListItem>  
  216.                          <asp:ListItem Value="SVC">El Salvador Colon</asp:ListItem>  
  217.                          <asp:ListItem Value="EEK">Estonian Kroon</asp:ListItem>  
  218.                          <asp:ListItem Value="ETB">Ethiopian Birr</asp:ListItem>  
  219.                          <asp:ListItem Value="EUR">Euro</asp:ListItem>  
  220.                          <asp:ListItem Value="FKP">Falkland Islands Pound</asp:ListItem>  
  221.                          <asp:ListItem Value="GMD">Gambian Dalasi</asp:ListItem>  
  222.                          <asp:ListItem Value="GHC">Ghanian Cedi</asp:ListItem>  
  223.                          <asp:ListItem Value="GIP">Gibraltar Pound</asp:ListItem>  
  224.                          <asp:ListItem Value="XAU">Gold Ounces</asp:ListItem>  
  225.                          <asp:ListItem Value="GTQ">Guatemala Quetzal</asp:ListItem>  
  226.                          <asp:ListItem Value="GNF">Guinea Franc</asp:ListItem>  
  227.                          <asp:ListItem Value="GYD">Guyana Dollar</asp:ListItem>  
  228.                          <asp:ListItem Value="HTG">Haiti Gourde</asp:ListItem>  
  229.                          <asp:ListItem Value="HNL">Honduras Lempira</asp:ListItem>  
  230.                          <asp:ListItem Value="HKD">Hong Kong Dollar</asp:ListItem>  
  231.                          <asp:ListItem Value="HUF">Hungarian Forint</asp:ListItem>  
  232.                          <asp:ListItem Value="ISK">Iceland Krona</asp:ListItem>  
  233.                          <asp:ListItem Value="INR">Indian Rupee</asp:ListItem>  
  234.                          <asp:ListItem Value="IDR">Indonesian Rupiah</asp:ListItem>  
  235.                          <asp:ListItem Value="IQD">Iraqi Dinar</asp:ListItem>  
  236.                          <asp:ListItem Value="ILS">Israeli Shekel</asp:ListItem>  
  237.                          <asp:ListItem Value="JMD">Jamaican Dollar</asp:ListItem>  
  238.                          <asp:ListItem Value="JPY">Japanese Yen</asp:ListItem>  
  239.                          <asp:ListItem Value="JOD">Jordanian Dinar</asp:ListItem>  
  240.                          <asp:ListItem Value="KZT">Kazakhstan Tenge</asp:ListItem>  
  241.                          <asp:ListItem Value="KES">Kenyan Shilling</asp:ListItem>  
  242.                          <asp:ListItem Value="KRW">Korean Won</asp:ListItem>  
  243.                          <asp:ListItem Value="KWD">Kuwaiti Dinar</asp:ListItem>  
  244.                          <asp:ListItem Value="LAK">Lao Kip</asp:ListItem>  
  245.                          <asp:ListItem Value="LVL">Latvian Lat</asp:ListItem>  
  246.                          <asp:ListItem Value="LBP">Lebanese Pound</asp:ListItem>  
  247.                          <asp:ListItem Value="LSL">Lesotho Loti</asp:ListItem>  
  248.                          <asp:ListItem Value="LRD">Liberian Dollar</asp:ListItem>  
  249.                          <asp:ListItem Value="LYD">Libyan Dinar</asp:ListItem>  
  250.                          <asp:ListItem Value="LTL">Lithuanian Lita</asp:ListItem>  
  251.                          <asp:ListItem Value="MOP">Macau Pataca</asp:ListItem>  
  252.                          <asp:ListItem Value="MKD">Macedonian Denar</asp:ListItem>  
  253.                          <asp:ListItem Value="MGF">Malagasy Franc</asp:ListItem>  
  254.                          <asp:ListItem Value="MWK">Malawi Kwacha</asp:ListItem>  
  255.                          <asp:ListItem Value="MYR">Malaysian Ringgit</asp:ListItem>  
  256.                          <asp:ListItem Value="MVR">Maldives Rufiyaa</asp:ListItem>  
  257.                          <asp:ListItem Value="MTL">Maltese Lira</asp:ListItem>  
  258.                          <asp:ListItem Value="MRO">Mauritania Ougulya</asp:ListItem>  
  259.                          <asp:ListItem Value="MUR">Mauritius Rupee</asp:ListItem>  
  260.                          <asp:ListItem Value="MXN">Mexican Peso</asp:ListItem>  
  261.                          <asp:ListItem Value="MDL">Moldovan Leu</asp:ListItem>  
  262.                          <asp:ListItem Value="MNT">Mongolian Tugrik</asp:ListItem>  
  263.                          <asp:ListItem Value="MAD">Moroccan Dirham</asp:ListItem>  
  264.                          <asp:ListItem Value="MZM">Mozambique Metical</asp:ListItem>  
  265.                          <asp:ListItem Value="MMK">Myanmar Kyat</asp:ListItem>  
  266.                          <asp:ListItem Value="NAD">Namibian Dollar</asp:ListItem>  
  267.                          <asp:ListItem Value="NPR">Nepalese Rupee</asp:ListItem>  
  268.                          <asp:ListItem Value="ANG">Neth Antilles Guilder</asp:ListItem>  
  269.                          <asp:ListItem Value="NZD">New Zealand Dollar</asp:ListItem>  
  270.                          <asp:ListItem Value="NIO">Nicaragua Cordoba</asp:ListItem>  
  271.                          <asp:ListItem Value="NGN">Nigerian Naira</asp:ListItem>  
  272.                          <asp:ListItem Value="KPW">North Korean Won</asp:ListItem>  
  273.                          <asp:ListItem Value="NOK">Norwegian Krone</asp:ListItem>  
  274.                          <asp:ListItem Value="OMR">Omani Rial</asp:ListItem>  
  275.                          <asp:ListItem Value="XPF">Pacific Franc</asp:ListItem>  
  276.                          <asp:ListItem Value="PKR">Pakistani Rupee</asp:ListItem>  
  277.                          <asp:ListItem Value="XPD">Palladium Ounces</asp:ListItem>  
  278.                          <asp:ListItem Value="PAB">Panama Balboa</asp:ListItem>  
  279.                          <asp:ListItem Value="PGK">Papua New Guinea Kina</asp:ListItem>  
  280.                          <asp:ListItem Value="PYG">Paraguayan Guarani</asp:ListItem>  
  281.                          <asp:ListItem Value="PEN">Peruvian Nuevo Sol</asp:ListItem>  
  282.                          <asp:ListItem Value="PHP">Philippine Peso</asp:ListItem>  
  283.                          <asp:ListItem Value="XPT">Platinum Ounces</asp:ListItem>  
  284.                          <asp:ListItem Value="PLN">Polish Zloty</asp:ListItem>  
  285.                          <asp:ListItem Value="QAR">Qatar Rial</asp:ListItem>  
  286.                          <asp:ListItem Value="ROL">Romanian Leu</asp:ListItem>  
  287.                          <asp:ListItem Value="RUB">Russian Rouble</asp:ListItem>  
  288.                          <asp:ListItem Value="WST">Samoa Tala</asp:ListItem>  
  289.                          <asp:ListItem Value="STD">Sao Tome Dobra</asp:ListItem>  
  290.                          <asp:ListItem Value="SAR">Saudi Arabian Riyal</asp:ListItem>  
  291.                          <asp:ListItem Value="SCR">Seychelles Rupee</asp:ListItem>  
  292.                          <asp:ListItem Value="SLL">Sierra Leone Leone</asp:ListItem>  
  293.                          <asp:ListItem Value="XAG">Silver Ounces</asp:ListItem>  
  294.                          <asp:ListItem Value="SGD">Singapore Dollar</asp:ListItem>  
  295.                          <asp:ListItem Value="SKK">Slovak Koruna</asp:ListItem>  
  296.                          <asp:ListItem Value="SIT">Slovenian Tolar</asp:ListItem>  
  297.                          <asp:ListItem Value="SBD">Solomon Islands Dollar</asp:ListItem>  
  298.                          <asp:ListItem Value="SOS">Somali Shilling</asp:ListItem>  
  299.                          <asp:ListItem Value="ZAR">South African Rand</asp:ListItem>  
  300.                          <asp:ListItem Value="LKR">Sri Lanka Rupee</asp:ListItem>  
  301.                          <asp:ListItem Value="SHP">St Helena Pound</asp:ListItem>  
  302.                          <asp:ListItem Value="SDD">Sudanese Dinar</asp:ListItem>  
  303.                          <asp:ListItem Value="SRG">Surinam Guilder</asp:ListItem>  
  304.                          <asp:ListItem Value="SZL">Swaziland Lilageni</asp:ListItem>  
  305.                          <asp:ListItem Value="SEK">Swedish Krona</asp:ListItem>  
  306.                          <asp:ListItem Value="TRY">Turkey Lira</asp:ListItem>  
  307.                          <asp:ListItem Value="CHF">Swiss Franc</asp:ListItem>  
  308.                          <asp:ListItem Value="SYP">Syrian Pound</asp:ListItem>  
  309.                          <asp:ListItem Value="TWD">Taiwan Dollar</asp:ListItem>  
  310.                          <asp:ListItem Value="TZS">Tanzanian Shilling</asp:ListItem>  
  311.                          <asp:ListItem Value="THB">Thai Baht</asp:ListItem>  
  312.                          <asp:ListItem Value="TOP">Tonga Pa'anga</asp:ListItem>  
  313.                          <asp:ListItem Value="TTD">Trinidad&Tobago Dollar</asp:ListItem>  
  314.                          <asp:ListItem Value="TND">Tunisian Dinar</asp:ListItem>  
  315.                          <asp:ListItem Value="TRL">Turkish Lira</asp:ListItem>  
  316.                          <asp:ListItem Value="USD">U.S. Dollar</asp:ListItem>  
  317.                          <asp:ListItem Value="AED">UAE Dirham</asp:ListItem>  
  318.                          <asp:ListItem Value="UGX">Ugandan Shilling</asp:ListItem>  
  319.                          <asp:ListItem Value="UAH">Ukraine Hryvnia</asp:ListItem>  
  320.                          <asp:ListItem Value="UYU">Uruguayan New Peso</asp:ListItem>  
  321.                          <asp:ListItem Value="VUV">Vanuatu Vatu</asp:ListItem>  
  322.                          <asp:ListItem Value="VEB">Venezuelan Bolivar</asp:ListItem>  
  323.                          <asp:ListItem Value="VND">Vietnam Dong</asp:ListItem>  
  324.                          <asp:ListItem Value="YER">Yemen Riyal</asp:ListItem>  
  325.                          <asp:ListItem Value="YUM">Yugoslav Dinar</asp:ListItem>  
  326.                          <asp:ListItem Value="ZMK">Zambian Kwacha</asp:ListItem>  
  327.                          <asp:ListItem Value="ZWD">Zimbabwe Dollar</asp:ListItem>  
  328.                     </asp:DropDownList>  
  329.                     <br />  
  330.                     <br />  
  331.                     <asp:Button ID="Button1" runat="server" Text="Click" OnClick="Button1_Click" />  
  332.                     <br />  
  333.                     <br />  
  334.                     <asp:Label ID="lblAmt" runat="server"></asp:Label>  
  335.                </div>  
  336.           </form>  
  337.      </body>  
  338.   
  339. </html> 
Now copy the following code into the Default.aspx.cs page:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Web;  
  4. using System.Web.UI;  
  5. using System.Web.UI.WebControls;  
  6.   
  7. public partial class _Default: System.Web.UI.Page {  
  8.     protected void Page_Load(object sender, EventArgs e) {}  
  9.     protected void Button1_Click(object sender, EventArgs e) k {  
  10.         // here we put all code in try-catch  
  11.         try {  
  12.             // create an object of CurrencyConvertor class  
  13.             myservice.CurrencyConvertor cc = new myservice.CurrencyConvertor();  
  14.             // create an object of Currency class  
  15.             myservice.Currency c = new myservice.Currency();  
  16.             // call ConversionRate method of CurrencyConvertor class  
  17.             // but it takes parameter of a Currency type so  
  18.             // here we get this type from enum  
  19.             double v = cc.ConversionRate((myservice.Currency) System.Enum.Parse(c.GetType(), drpFrom.SelectedValue), ((myservice.Currency) System.Enum.Parse(c.GetType(), drpTo.SelectedValue)));  
  20.             double unit = 0;  
  21.             if ((txtAmt.Text.Trim() != "") || (txtAmt.Text == null)) {  
  22.                 unit = Convert.ToDouble(txtAmt.Text.Trim());  
  23.             }  
  24.             double amt = v * (unit);  
  25.             lblAmt.Text = "Total Amount =" + amt;  
  26.         } catch (Exception ex) {  
  27.             lblAmt.Text = "Error";  
  28.         }  
  29.     }  

Finally, run your webpage.
 
Current Curency Rate Output


Recommended Free Ebook
Similar Articles