.net C# 获取QQ天气代码

作者:袖梨 2022-06-25

.net C# 获取QQ天气代码

///


    /// 2011-06-16 ?T聚文
    ///

    public partial class QQweather : System.Web.UI.Page
    {

        public string selectcity = "1";
        ///


        ///
        ///

        ///
        ///
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
            HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri("https教程://www.dusystem.com/QQweather.asp教程x"));
            req.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            selectcity = DropDownList1.SelectedValue.ToString();
            if (!IsPostBack)
            {

                this.DropDownList1.DataSource = CreateDataSource();
                DropDownList1.DataTextField = "WeatherTextField";
                DropDownList1.DataValueField = "WeatherValueField";

                // Bind the data to the control.
                DropDownList1.DataBind();

                // Set the default selected item, if desired.
                DropDownList1.SelectedIndex = 0;
                selectcity = @"1";
            }


        }
        ///


        ///
        ///

        ///
        ///
        protected void Button1_Click(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
            HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri("https://www.dusystem.com/QQweather.aspx"));
            req.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            selectcity = DropDownList1.SelectedValue.ToString();
        }
        ///
        /// <%# selectcity%>
        ///

        ///
        ICollection CreateDataSource()
        {

        
            DataTable dt = new DataTable();           
            dt.Columns.Add(new DataColumn("WeatherTextField", typeof(String)));
            dt.Columns.Add(new DataColumn("WeatherValueField", typeof(String)));
            dt.Rows.Add(CreateRow("香港", "1", dt));
            dt.Rows.Add(CreateRow("澳?", "2", dt));
            dt.Rows.Add(CreateRow("哈???I", "17", dt));
            dt.Rows.Add(CreateRow("?豸?木?", "28", dt));
            dt.Rows.Add(CreateRow("西??", "56", dt));
            dt.Rows.Add(CreateRow("?州", "57", dt));
            dt.Rows.Add(CreateRow("呼和浩特", "69", dt));
            dt.Rows.Add(CreateRow("?川", "78", dt));
            dt.Rows.Add(CreateRow("石家?", "82", dt));
            dt.Rows.Add(CreateRow("太原", "84", dt));
            dt.Rows.Add(CreateRow("?春 ", "103", dt));
            dt.Rows.Add(CreateRow("?c? ", "115", dt));
            dt.Rows.Add(CreateRow("北京 ", "125", dt));
            dt.Rows.Add(CreateRow("天津 ", "127", dt));
            dt.Rows.Add(CreateRow("?? ", "140", dt));
            dt.Rows.Add(CreateRow("拉? ", "150", dt));
            dt.Rows.Add(CreateRow("成都 ", "166", dt));
            dt.Rows.Add(CreateRow("昆明 ", "179", dt));
            dt.Rows.Add(CreateRow("西安 ", "186", dt));
            dt.Rows.Add(CreateRow("?州 ", "189", dt));
            dt.Rows.Add(CreateRow("武?h ", "211", dt));
            dt.Rows.Add(CreateRow("重?c ", "212", dt));
            dt.Rows.Add(CreateRow("?沙 ", "218", dt));
            dt.Rows.Add(CreateRow("?? ", "227", dt));
            dt.Rows.Add(CreateRow("桂林 ", "232", dt));
            dt.Rows.Add(CreateRow("南京 ", "244", dt));
            dt.Rows.Add(CreateRow("合肥 ", "248", dt));
            dt.Rows.Add(CreateRow("上海 ", "252", dt));
            dt.Rows.Add(CreateRow("杭州 ", "255", dt));
            dt.Rows.Add(CreateRow("南昌 ", "264", dt));
            dt.Rows.Add(CreateRow("福州 ", "276", dt));
            dt.Rows.Add(CreateRow("?北 ", "280", dt));
            dt.Rows.Add(CreateRow("?B? ", "287", dt));
            dt.Rows.Add(CreateRow("?V州 ", "292", dt));
            dt.Rows.Add(CreateRow("南?? ", "295", dt));
            dt.Rows.Add(CreateRow("深圳 ", "296", dt));
            dt.Rows.Add(CreateRow("海口 ", "303", dt));
            DataView dv = new DataView(dt);
            return dv;

        }
        ///


        ///
        ///

        ///
        ///
        ///
        ///
        DataRow CreateRow(String Text, String Value, DataTable dt)
        {
            DataRow dr = dt.NewRow();
            dr[0] = Text;
            dr[1] = Value;
            return dr;

        }
        public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            //直接确认,否则打不开
            return true;
        }

相关文章

精彩推荐