50 bài tập ASP cho người mới học

Chia sẻ bởi Lê Thị Xuân Huyền | Ngày 26/04/2019 | 104

Chia sẻ tài liệu: 50 bài tập ASP cho người mới học thuộc Công nghệ thông tin

Nội dung tài liệu:

50 bài tập ASP cho người mới bắt đầu
Bộ bài tập ASP cơ bản, gồm 50 bài, từng bước từng bước, tương đối dễ học. Mong các bạn sưu tầm tiếp và cập nhật thêm, để bộ sưu tập này nhiều lên và hữu ích hơn.
---------------------------
Băng qua việc cài đặt trình IIS trong WINDOWS, tạo thư mục ViduASP và soạn thảo các bài tập vào đó, Share thư mục ViduASP thành WEB bằng cách chọn WebSharing. Cuối cùng có thể chạy bằng địa chỉ trên Address của IE là http://localhost/viduAsp/tenfile.asp


Phần I: ASP cơ bản

1. Ghi dòng text ra trang web



<% response.write("Hello World!")%>



2. Định dạng text kết hợp với các thẻ html

<% response.write("

You can use HTML tags to format the text!

") %>
<%
response.write("

This text is styled with the style attribute!

")
%>



3. Định nghĩa biến trong Asp


<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>



4. Định nghĩa một dãy


<%
Dim famname(6),i
famname(1) = "Jan Egil"
famname(2) = "Tove"
famname(3) = "Hege"
famname(4) = "Stale"
famname(5) = "Kai Jim"
famname(6) = "Borge"

For i = 1 to 6
response.write(famname(i) & "
")
Next
%>




5. Ví dụ về vòng lặp

<%
dim i
for i=1 to 6
response.write("Header " & i & "")
next
%>



6. Câu lệnh If và hàm thời gian dạng đơn giản

<%
dim h
h=hour(now())
response.write("

" & now())
response.write(" (Norwegian Time)

")
If h<12 then
response.write("Good Morning!")
else
response.write("Good day!")
end if
%>



7. Sử dụng lồng JavaScript (đối tượng Date trong JavaScript)
<%@ language="javascript" %>


<%
var d=new Date()
var h=d.getHours()
Response.Write("

")
Response.Write(d + " (Norwegian Time)")
Response.Write("

")
if (h<12)
{
Response.Write("Good Morning!")
}
else
{
Response.Write("Good day!")
}
%>



8. Date và Time trong VbScript


Today`s date is: <%response.write(date())%>.


The server`s local time is: <%response.write(time())%>.



9. Tính số ngày, tháng, năm từ năm hiện tại cho đến năm 3000


Countdown to year 3000:



<%millennium=cdate("1/1/3000 00:00:00")%>
It is
<%response.write(DateDiff("yyyy", Now(), millennium))%>
years to year 3000!


It is
<%response.write(DateDiff("m", Now(), millennium))%>
months to year 3000!


It is
<%response.write(DateDiff("ww", Now(), millennium))%>
weeks to year 3000!


It is
<%response.write(DateDiff("d", Now(), millennium))%>
days to year 3000!


It is
<%response.write(DateDiff("h", Now(), millennium))%>
hours to year 3000!


It is
<%response.write(DateDiff("n", Now(), millennium))%>
minutes to year 3000!


It is
<%response.write(DateDiff("s", Now(), millennium))%>
seconds to year 3000!



* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...

Người chia sẻ: Lê Thị Xuân Huyền
Dung lượng: | Lượt tài: 1
Loại file:
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)