
Bài 3:
SERVER CONTROL
3.1. Html Server control
3.2. Web Server control
3.3. Client-Side Callback

3.1 HTML Server Control
•Khái niệm
•Cách tạo
•Thứ bậc
•Các sự kiện
•Xử lý dữ liệu

Khái niệm
•HTML control là các đoạn mã dùng tạo các điều khiển
trên giao diện
•HTML control thường chỉ được sử lý ngay tại Web
Browser (< h> , < a> , < input> …)
•Các HTML control có thể được xử lý ngay tại phía server
bằng cách chuyển chúng thành các HTML server control

Ví dụ
< html xmlns= "http://www.w3.org/1999/xhtml">
< head runat= "server">
<title>Các điều khiển giao diện</title>
< script type= "text/javascript">
function Tinh() {
var x, y;
x = parseInt(document.getElementById("txtA").value);
y = parseInt(document.getElementById("txtB").value);
document.getElementById("txtTong").value = x + y;
}
< /script>
< /head>
< body>
< form id= "form_chinh" >
Nhập số A:<input type="text" id="txtA" /> <br />
Nhập số B:<input type="text" id="txtB" /> <br />
<input type="button" onclick="Tinh();" name="btnTinh" value="Tổng" /><br />
Tổng là:<input type="text" id="txtTong" /><br />
< /form>
< /body>
< /html>

Cách tạo
•Cú pháp:
< TagName runat= “server”> < / TagName>
•Ví dụ:
< input type= “text” name= “txtA” runat= “server”/>
•Tất cả HTML Server Control phải được đặt trong tag <form> với
thuộc tính runat = “server”
< form id= "form1" runat= "server">
……
< /form>