将数据显示为警报而不是文档树

时间:2015-06-12 16:13:14

标签: c# xml web-services asmx

如何将信息检索为警报而不是"文档树"来自XML文件。

  

此XML文件似乎没有任何关联的样式信息   用它。文档树如下所示。

<string xmlns="http://tempuri.org/">-10</string>

的index.html:

<html>
    <head>
        <title></title>
    </head>
    <body>
        <script>
            function ShowResult() {
                alert(  );   
            }
        </script>
        <h1>CONVIERTA facilmente su temperatura a Celsius o Fahrenheit </h1>
        <br />
        <div id="divMessage" class="errordisplay" style="display: none"></div>
        <form action='WebService2.asmx/FahrenheitToCelsius' method="post" target="_self" id="Fahrenheit">
            <table>
                <tr>
                    <td>Fahrenheit a Celsius:</td>
                    <td>
                        <input class="frmInput" type="text" size="30" name="Fahrenheit">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td align="right">
                        <input type="submit" onclick="ShowResult()" value="Submit" class="button">
                    </td>
                </tr>
            </table>
        </form>
        <form action='WebService2.asmx/CelsiusToFahrenheit'
              method="post" target="__self">
            <table>
                <tr>
                    <td>Celsius a Fahrenheit:</td>
                    <td>
                        <input class="frmInput" type="text" size="30" name="Celsius">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td align="right">
                        <input type="submit" value="Submit" class="button" onclick="ShowResult()" >
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

WebService2.asmx.cs:

using System.Web;
using System.Web.Services;

namespace WebApplication4
{
    /// <summary>
    /// Summary description for WebService2
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService2 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string FahrenheitToCelsius(string Fahrenheit)
        {
            object fahr = null;
            fahr = Fahrenheit.Replace(",", ".").Trim(' ');
            if (fahr == "")
            {
                return "Error";
            }
            int returnVal = ((((Convert.ToInt32(fahr)) - 32) / 9) * 5);
            return returnVal.ToString();
        }

        [WebMethod]
        public string CelsiusToFahrenheit(string Celsius)
        {
            object cel = null;
            cel = Celsius.Replace(",", ".").Trim(' ');
            if (cel == "")
            {
                return "Error";
            }
            int returnVal = ((((Convert.ToInt32(cel)) * 9) / 5) + 32);
            return returnVal.ToString();
        }
    }
}

编辑...添加快照

enter image description here enter image description here

0 个答案:

没有答案