我想在http://www.webservicex.com/CurrencyConvertor.asmx?wsdl使用货币转换器。但它不起作用我在下拉列表菜单中什么都没有。
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.webservicex.www;
public partial class cc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//using web service at http://www.webservicex.com/CurrencyConvertor.asmx?wsdl
double rate = 0, result = 0;
Currency curr1, curr2;
try
{
CurrencyConvertor ws = new CurrencyConvertor();
curr1 = (Currency)Enum.Parse(typeof(Currency), DropDownList1.SelectedItem.Value);
curr2 = (Currency)Enum.Parse(typeof(Currency), DropDownList2.SelectedItem.Value);
rate = ws.ConversionRate(curr1, curr2);
result = System.Convert.ToDouble(TextBox1.Text) * rate;
Label2.Text = "The exchange rate between" + DropDownList1.SelectedItem.Text + " and " + DropDownList2.SelectedItem.Text + " is " + rate;
Label3.Text = "Converted " + TextBox1.Text + " to " + result;
}
catch
{
Label2.Text = "Web service not available please try again later.";
}
}
}
谢谢