asp.net夜話之三:表單和控制項

來源:互聯網
上載者:User

在今天我主要要介紹的有如下知識點:

HTML表單的提交方式

HTM控制項

擷取HTML表單內容

亂碼問題

SQL注入

伺服器端表單

HTML伺服器控制項

HTML表單的提交方式

對於一個普通HTML表單來說,它有兩個重要的屬性:action和method。

action屬性指明當前表單提交之後由哪個程式來處理,這個處理常式可以是任何動態網頁或者servlet或者CGI(Common Gateway Interface),在asp.net裡面一般都是都aspx頁面來處理。

method屬性指明form表單的提交方式。它有兩個可能值get和post。

下面我們以一個例子來說明get和post的區別。用Dreamweaver8建立兩個aspx頁面,分別為Register.aspx和GetUserInfo.aspx。暫時我們不需要在GetUserInfo.aspx頁面寫任何代碼,Register.aspx頁面的代碼如下:

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>使用者註冊</title>
</head>
<body>
<form action="GetUserInfo.aspx" method="get">
<table border="1" width="400px">
<tr><td colspan="2">使用者註冊</td></tr>
<tr><td>使用者名稱</td><td><input type="text" name="username" /></td></tr>
<tr><td>密碼</td><td><input type="password" name="pwd" /></td></tr>
<tr><td><input type="submit" value="提交" /></td><td><input type="reset" value="重設" /></td></tr>
</table>
</form>
</body>
</html>

聯繫我們

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