Problem Regarding .NET coding (Using Java Script,Ajax) Plz Plz Help me.

ajax , csharp , java , xml Greece
  • 13 years ago
    In This coding  we r doing the currency conversion  The Rsult is displaying lick this

    144 USD = NaN INR

    Whay hear NAN(Not a number) is displaying

    plz help me and what is the changes and how to do that plz tell me

    In web.config I am using this Rss feed:


    <add key="CurrencyLink" value=""/>




    In JavaScript :


    //This particular function  retreives and displays the currency results of the usered selected input

    function DisplayCurrencyValue(link,currency)


            var str,objXMLNode,objXMLDoc,objEmployee,strHTML;;

            var stri=AJAXUtilities.GetCurrencyValue(link,currency);

              str = stri.value;

              var result= parseFloat(str);       

              var value=parseFloat(document.getElementById("txtConvert").value)







              var city=document.getElementById("ddlTo");

              var url=document.getElementById("ddlFrom");

              var path=url.options[url.selectedIndex].text;

              var pathCurr=url.options[url.selectedIndex].value;

              var currencyAbr=pathCurr.substring(pathCurr.length-7,pathCurr.length-7+3);        

              var curr=city.options[city.selectedIndex].value;


              var str=value+" "+currencyAbr+" = "+ Result +" "+curr;       


             // document.getElementById("txtConvert").focus();    



    //This particular function gets the user selected input and invokes the fucnction which retreives the details

    function DisplayCurrencyResult()


       var city=document.getElementById("ddlTo");

       var url=document.getElementById("ddlFrom");

       var path=url.options[url.selectedIndex].value;

       var curr=city.options[city.selectedIndex].value;


    In AJAX coding :


    //This particular method returns xml document with currency details


            public XmlDocument GetCurrencyDetails()



                DataSet ds3 = new DataSet();

                string currencyUrl = ConfigurationSettings.AppSettings["CurrencyLink"].ToString();          

                ds3.ReadXml(currencyUrl, XmlReadMode.Auto);

                XmlDocument xmlDoc = new XmlDocument();


                return xmlDoc;



            //This particular method returns the respective value of the currency as a string


            public string GetCurrencyValue(string url, string currency)


                DataSet ds3 = new DataSet();

                ds3.ReadXml(url, XmlReadMode.Auto);         

                DataTable table = ds3.Tables[3];

                string curren = currency.Trim();

                string title = "";

                string rate = "";

                string exchange = "";

                string outPut = "";

                foreach (DataRow row in table.Rows)


                    title = row["title"].ToString();

                    int endPoint = title.IndexOf("=");

                    int startPoint = title.IndexOf("(");

                    int ePoint = title.IndexOf("(");

                    rate = title.Substring(endPoint + 2);

                    exchange = (rate.Substring(0, 3));

                    if (exchange.Equals(curren))


                        outPut = rate.Substring(5, (rate.Length - 1) - 5);


                    rate = title.Substring(startPoint + 1, 3);


                decimal tr = Convert.ToDecimal(rate.Substring(0, rate.Length - 1));

                tr = tr * 100;

                //XmlDocument xmlDoc = new XmlDocument();

                return outPut;



    In Index.aspx.cs



    //Binds the Currency detatils to the dropdownlist

        public void BindCurrency()


            CurrencyDetails newCurrency = new CurrencyDetails();

            CurrencyDetailsCollection newCurrencyColl = new CurrencyDetailsCollection();

            newCurrencyColl = newCurrency.getAllCurrencies();



            if (newCurrencyColl.Count > 0)


                ddlFrom.DataSource = newCurrencyColl;

                ddlFrom.DataTextField = "CurrencyDesc";

                ddlFrom.DataValueField = "CurrencyURL";


                ddlTo.DataSource = newCurrencyColl;

                ddlTo.DataTextField = "CurrencyDesc";

                ddlTo.DataValueField = "currency_abbr";


                ddlFrom.SelectedIndex = 45;

                ddlTo.SelectedIndex = 45;



Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer Science is no more about computers than astronomy is about telescopes.” - E. W. Dijkstra