asp.net mobile phone number location query implementation code

Source: Internet
Author: User

Use the browser to open the phone number Query Web site, with the above steps to find the address of his call, and finally write code as follows:

  code is as follows
using System
using System.Windows.Forms;
using System.Xml;
namespace Hnvote
{
& nbsp;   public partial class Mobile:form
    {
      & nbsp Public Mobile ()
        {
             InitializeComponent ();
       }
        private  Static string[] Getmobileinfo (string number)
         {
            try
            {
                 XmlDocument xmldocument = new XmlDocument ();
                XmlDocument. Load ("http://api.showji.com/Locating/default.aspx?m=" + number);
                XmlNamespaceManager cx = new XmlNamespaceManager (xmldocument.nametable);
                CX. AddNamespace ("Content", "http://api.showji.com/Locating/");
                XmlNodeList Nodes = xmldocument.selectnodes 

("//content:queryresult|//content:mobile|//content:province|//content:city|//

Content:corp|//content:card|//content:areacode|//content:postcode ", CX);


if (nodes. Count = 8)


                {


if ("True"). Equals (Nodes[1]. innertext))


                    {


return new string[]


                                   {


Nodes[0]. InnerText, nodes[2]. InnerText, Nodes[3]. InnerText, Nodes[4]. InnerText,


NODES[5]. InnerText, Nodes[6]. InnerText + nodes[7]. InnerText


                                   };


                    }


                }


return new string[] {"false"};


            }


catch (Exception)


            {


return new string[] {"false"};


            }


        }


private void Button1_Click (object sender, EventArgs e)


        {


Try


            {


string[] num = Getmobileinfo (TextBox1.Text);


MessageBox.Show ("Search number:" + num[0] + "N Attribution Province:" + num[1] + "N Attribution City:" + num[2] + "N City Code:" + num[3] + "N City Zip Code:" +


Num[4] + "n Card type:" + num[5], "Query results", MessageBoxButtons.OK, Messageboxicon.informatio n);


            }


catch (Exception ex)


            {


MessageBox.Show (ex. Message, "error hint", messageboxbuttons.ok,messageboxicon.warning);


}


        }


private void Textbox1_keydown (object sender, KeyEventArgs e)


        {


if (e.keycode==keys.enter)


            {


button1_click (sender,e);


            }


        }


    }


}  


 

Interface:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.