i use this code
public class Rate
{
public string to { get; set; }
public string from { get; set; }
public double rate { get; set; }
}
protected void Convert(object sender, EventArgs e)
{
double amount = 0d;
if (double.TryParse(txtAmount.Text.Trim(), out amount))
{
string url = string.Format("http://www.google.co.in/ig/calculator?hl=en&q={0}{2}%3D%3F{1}", ddlFrom.SelectedItem.Value, ddlTo.SelectedItem.Value);
WebClient client = new WebClient();
string rates = client.DownloadString(url);
Rate rate = new JavaScriptSerializer().Deserialize<Rate>(rates);
double converted_amount = amount * rate.rate;
string message = ddlFrom.SelectedItem.Value + ": " + amount + "\\n";
message += ddlTo.SelectedItem.Value + ": " + converted_amount + "\\n";
message += "Rate: 1 " + ddlFrom.SelectedItem.Value + " = " + rate.rate + " " + ddlTo.SelectedItem.Value;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Invalid amount value.');", true);
}
}
but the url 'http://rate-exchange.appspot.com/currency?from={0}&to={1}' use in this code give error
error:The remote server returned an error: (404) Not Found.
Than i use this url 'http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json'
but it cannot convert
after than i use this url 'http://www.google.co.in/ig/calculator?hl=en&q={2}{0}%3D%3F{1}' but it also give error
error: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
any help?