WebForms 開發基礎

來源:互聯網
上載者:User

標籤:類型   server   set   元素   click   按鈕   end   右鍵   點擊事件   

webform開發方式

xml - 可擴充的標記語言
HTML - 超文字標記語言 (HTML)

運行:
點擊啟動按鈕 - 好處:可以卡斷點
弊端:啟動特別慢

在html上右鍵,在瀏覽器中查看 - 好處:啟動特別快
弊端:無法卡斷點

表單元素
一共有12個
分成三大類

文本類
<input type="text" /> - 文字框
<input type="password" /> - 密碼框
<input type="hidden" /> - 隱藏欄位
<textarea></textarea> - 文本域

按鈕類
<input type="button" />-普通按鈕
<input type="submit" />-提交按鈕
<input type="reset" />  -重設按鈕
<input type="image" />-圖片按鈕


選擇類
<input type="radio" />-單選框
<input type="checkbox" />-複選框
<select>                       -下拉選框
<option></option>
<option></option>
</select>

<input type="file" />  -選擇路徑

事件委託寫法
在page_load事件中 輸入:
Button1.Click += Button1_Click;//添加按鈕      雙擊Tab鍵產生Button1的點擊事件

1 protected void Page_Load(object sender, EventArgs e)2     {3         Button1.Click += Button1_Click;4     }5 6     void Button1_Click(object sender, EventArgs e)7     {8         9     }

 

http無狀態性
每一次頁面提交導致的重新整理,或者是人為的重新整理,都會將原有頁面登出掉,哪怕兩個頁面是一樣的,他們也不是同一個頁面了

IsPostBack 是Page類有一個bool類型的屬性,用來判斷針對當前頁面的請求是第一次還是非第一次,IsPostBack=false時表示是第一次請求,當IsPostBack=true時,表示是非第一次請求。因

為第一次請求的時候會執行Page_Load,在非第一次請求的時候也會執行Page_Load。

protected void Page_Load(object sender, EventArgs e)    {        if (IsPostBack == false)//頁面第一次請求時發生        {            TextBox1.Text = "123456";        }        Button1.Click += Button1_Click;//事件委託    }    void Button1_Click(object sender, EventArgs e)    {        Label1.Text = TextBox1.Text;    }

 三層結構

  介面層:Html、Css、Js

  商務邏輯層:C#

  資料訪問層:ado.net    sqlserver

 

WebForms 開發基礎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.