asp.net 不用模板產生靜態頁面

來源:互聯網
上載者:User
 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 表單設計器產生的程式碼#region Web 表單設計器產生的程式碼
28        override protected void OnInit(EventArgs e)
29        {
30            //
31            // CODEGEN: 該調用是 ASP.NET Web 表單設計器所必需的。
32            //
33            InitializeComponent();
34            base.OnInit(e);
35        }
36        
37        /**//// <summary>
38        /// 設計器支援所需的方法 - 不要使用代碼編輯器修改
39        /// 此方法的內容。
40        /// </summary>
41        private void InitializeComponent()
42        {    
43            this.Button1.Click += new System.EventHandler(this.Button1_Click);
44            this.Load += new System.EventHandler(this.Page_Load);
45
46        }
47        #endregion
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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.