Currency Conversion using webservice in asp.net

Description:-

In this tutorials we will see about how to convert currency using web service in dot net. here is the demo example to convert currency in dot net using web service.

Add web reference from given URL. It's Free

Default.aspx:-

<div>
  <asp:Literal ID="ltrfrom" runat="server" Text="Select Currency to convert :"></asp:Literal>
  <asp:DropDownList ID="ddlFrom" runat="server" Style="vertical-align: middle;">   </asp:DropDownList>
  <br />
  <asp:Literal ID="ltrTo" runat="server" Text="Select Currency convert to :"></asp:Literal>
  <asp:DropDownList ID="ddlTo" runat="server" Style="vertical-align: middle;"> </asp:DropDownList>
  <br />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:TextBox ID="txtResult" runat="server" ></asp:TextBox>

Default.aspx.cs:-

using SampleCSharpApplication.net.webservicex.www;
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
  {
    Currency cur = new Currency();
    Array arr;
    arr = System.Enum.GetValues(cur.GetType());
    ddlFrom.DataSource = arr;
    ddlFrom.DataBind();
    ddlTo.DataSource = arr;
    ddlTo.DataBind();
  }
}

protected void Button1_Click(object sender, EventArgs e)
{
  CurrencyConvertor CC = new CurrencyConvertor();
  Currency cur = new Currency();
  txtResult.Text = CC.ConversionRate((Currency)System.Enum.Parse(cur.GetType(), 
  ddlFrom.Text), (Currency)System.Enum.Parse(cur.GetType(), 
  ddlTo.Text)).ToString();
}

Related Posts

Previous
Next Post »

1 comments:

comments

Thanks for comments.....