Sun_china

交流更多,收获更多?

博客园 首页 新随笔 联系 订阅 管理
 1using System;
 2using System.Collections;
 3using System.ComponentModel;
 4using System.Data;
 5using System.Drawing;
 6using System.Web;
 7using System.Web.SessionState;
 8using System.Web.UI;
 9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11
12namespace WebApplication2
13{
14    /// <summary>
15    /// WebForm1 的摘要说明。
16    /// </summary>

17    public class WebForm1 : System.Web.UI.Page
18    {
19        protected System.Web.UI.WebControls.Button Button1;
20        protected System.Web.UI.WebControls.Label Label1;
21    
22        private void Page_Load(object sender, System.EventArgs e)
23        {
24            // 在此处放置用户代码以初始化页面
25        }

26
27        Web 窗体设计器生成的代码
48
49        private void Button1_Click(object sender, System.EventArgs e)
50        {
51            string url="http://www.sina.com.cn";
52            System.Net.WebRequest wReq = System.Net.WebRequest.Create(url);
53            System.Net.WebResponse wResp =wReq.GetResponse();
54            System.IO.Stream respStream  = wResp.GetResponseStream();
55            System.IO.StreamReader reader = new System.IO.StreamReader(respStream, System.Text.Encoding.GetEncoding("gb2312"));
56
57            Label1.Text=reader.ReadToEnd();
58        }

59    }

60}

61
posted on 2007-04-23 16:57  Sun_china  阅读(301)  评论(1编辑  收藏  举报