1
Reply

Exception occur with web service

Faisal Ansari

Faisal Ansari

Aug 27 2011 6:45 AM
3.4k
hello guys how r u ?

i am in problem with web service and exception occur which i unable to understand kindly help me about it .

my code is given below,

service url: http://www.webservicex.net/CurrencyConvertor.asmx.

csharp code:
=============

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Services;
using System.Web.Services.Description;
using CurrencyConvertor;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ddlFrom.DataSource = Enum.GetValues(typeof(CurrencyConvertor.Currency));
            ddlFrom.DataBind();
            ddlTo.DataSource = Enum.GetValues(typeof(CurrencyConvertor.Currency));
            ddlTo.DataBind();
        }
        lblMessage.Visible = false;
    }
    protected void btnConvert_Click(object sender, EventArgs e)
    {
        if (txtAmount.Text != null && txtAmount.Text != "")
        {
            CurrencyConvertor.CurrencyConvertor conver = new CurrencyConvertor.CurrencyConvertor();
            CurrencyConvertor.Currency From = (CurrencyConvertor.Currency)Enum.Parse(typeof(CurrencyConvertor.Currency), ddlFrom.SelectedValue.ToString(), true);
            CurrencyConvertor.Currency To = (CurrencyConvertor.Currency)Enum.Parse(typeof(CurrencyConvertor.Currency), ddlTo.SelectedValue.ToString(), true);
            double d = conver.ConversionRate(From, To);
            lblMessage.Visible = true;
            lblMessage.Text = (d * Convert.ToDouble(txtAmount.Text)).ToString();
        }
        else
        {
            lblMessage.Visible = true;
            lblMessage.ForeColor = System.Drawing.Color.Red;
            lblMessage.Text = "Please Enter The Amount First !!!";
        }
    }
}

Reply soon 
its urgent please.
thanks.

Answers (1)