Курс валюты
hi I'm new to dotnet platform...I want to know the code for currency exchange rate in asp.net..can any one help me?
Что я уже пробовал:
Это мой код
ASP.Net код
<div> <table> <tr> <td> <asp:Label ID="lbl_Amount" runat="server" Text="Amount"></asp:Label></td> <td> <asp:TextBox ID="txt_amount" runat="server"></asp:TextBox> </td></tr> <tr> <td> <asp:Label ID="lbl_FromCurrency" runat="server" Text="From Currency"></asp:Label> </td> <td> <asp:TextBox ID="txt_fromCurrency" runat="server"></asp:TextBox> </td></tr> <tr> <td> <asp:Label ID="lbl_toCurrency" runat="server" Text="To Currency"></asp:Label></td> <td> <asp:TextBox ID="txt_ToCurrency" runat="server"></asp:TextBox></td> </tr> <tr><td> <asp:Label ID="lbl_value" runat="server" Text=""></asp:Label></td> <td> <asp:Button ID="Btn_Convert" runat="server" Text="Convert" OnClick="CurrencyConversion"/></td></tr></table> </div>
Код C#
public string CurrencyConversion(decimal amount, string fromCurrency, string toCurrency) { WebClient web = new WebClient(); string url = string.Format("https://www.google.com/finance/converter?from={0}&to={1}&a={2}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount); string response = web.DownloadString(url); Regex regex = new Regex("<span class=bld>(.*?)</span>"); var result = regex.Match(response).Groups[1].Value; return result; }