Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<asp:TextBox runat="server" ID="txtSymbol" />
<asp:Button Text="Get Value" runat="server" OnClick="OnConvert" /><hr />
Rate : <asp:Label ID="lblValue" runat="server" />
Code
C#
protected void OnConvert(object sender, EventArgs e)
{
string json = new System.Net.WebClient()
.DownloadString("https://openexchangerates.org/api/latest.json?app_id=APP_Key&symbols=" + txtSymbol.Text.Trim());
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
CurrencyRate rates = js.Deserialize<CurrencyRate>(json);
KeyValuePair<string, decimal> rate = rates.Rates.FirstOrDefault();
decimal currentrate = decimal.Parse(rate.Value.ToString());
lblValue.Text = currentrate.ToString();
}
public class CurrencyRate
{
public string Disclaimer { get; set; }
public string License { get; set; }
public int TimeStamp { get; set; }
public string Base { get; set; }
public Dictionary<string, decimal> Rates { get; set; }
}
VB.Net
Protected Sub OnConvert(ByVal sender As Object, ByVal e As EventArgs)
Dim json As String = New Net.WebClient() _
.DownloadString("https://openexchangerates.org/api/latest.json?app_id=APP_Key&symbols=" & txtSymbol.Text.Trim())
Dim js As Script.Serialization.JavaScriptSerializer = New Script.Serialization.JavaScriptSerializer()
Dim rates As CurrencyRate = js.Deserialize(Of CurrencyRate)(json)
Dim rate As KeyValuePair(Of String, Decimal) = rates.Rates.FirstOrDefault()
Dim currentrate As Decimal = Decimal.Parse(rate.Value.ToString())
lblValue.Text = currentrate.ToString()
End Sub
Public Class CurrencyRate
Public Property Disclaimer As String
Public Property License As String
Public Property TimeStamp As Integer
Public Property Base As String
Public Property Rates As Dictionary(Of String, Decimal)
End Class
Screenshot