Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<asp:TextBox runat="server" ID="txtRate" AutoPostBack="true" OnTextChanged="TextChanged" /><br />
<asp:Label ID="lblValue" runat="server" />
Code
C#
protected void TextChanged(object sender, EventArgs e)
{
string json = (new System.Net.WebClient()).DownloadString("https://api.exchangeratesapi.io/latest");
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
KeyValuePair<string, object> rates = js.Deserialize<Dictionary<string, object>>(json)
.Where(x => x.Key == "rates").FirstOrDefault();
KeyValuePair<string, object> keyValue = (rates.Value as Dictionary<string, object>)
.Where(x => x.Key == txtRate.Text).FirstOrDefault();
if (keyValue.Value != null)
{
lblValue.Text = keyValue.Value.ToString();
}
}
VB.Net
Protected Sub TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim json As String = (New System.Net.WebClient()).DownloadString("https://api.exchangeratesapi.io/latest")
Dim js As Script.Serialization.JavaScriptSerializer = New Script.Serialization.JavaScriptSerializer()
Dim rates As KeyValuePair(Of String, Object) = js.Deserialize(Of Dictionary(Of String, Object))(json) _
.Where(Function(x) x.Key = "rates").FirstOrDefault()
Dim keyValue As KeyValuePair(Of String, Object) = TryCast(rates.Value, Dictionary(Of String, Object)) _
.Where(Function(x) x.Key = txtRate.Text).FirstOrDefault()
If keyValue.Value IsNot Nothing Then
lblValue.Text = keyValue.Value.ToString()
End If
End Sub
Screenshot