0
Tải bản đầy đủ (.docx) (41 trang)

TẠO ỨNG DỤNG WEB TRÊN IIS

Một phần của tài liệu BAN NHAP 2 (Trang 32 -35 )

Một Web Server có thể quản lý nhiều ứng dụng Web đồng thời. Thông thường, bạn sẽ tổ chức một thư mục con trong wwwroot cho mỗi ứng dụng nhưng bạn cũng có thể tạo ánh xạ từ một thư mục khác. Nếu bạn đặt thư mục trong wwwroot, IIS sẽ tự động liệt kê nó trong mục Default Web Site. Nếu muốn tạo một thư mục nằm ngoài thư mục wwwroot thành một web site, chúng ta cần tạo Virtual Directory liên kết đến thư mục đó.

Nhập vào tên alias cho thư mục ảo.

Chọn nút Browse để chọn thư mục muốn ánh xạ. Tiếp đó, bạn sẽ phải đặt một số cấu hình khởi đầu cho web site, những thông tin này có thể cấu hình lại tương tự như với Default Web Site ở trên.

4.4.11 TẠO MỘT ỨNG DỤNG WEB VỚI ASP.NET

Bạn soạn thảo đoạn code sau trong notepad hoặc notepad++ <script runat="server">

Sub Page_Load

lbl1.Text="The date and time is " & now() End Sub

</script> <html> <body>

<h3><asp:label id="lbl1" runat="server" /></h3> </form>

</body> </html>

Sau đó lưu nó dưới một tên file có phần mở rộng là .aspx. Lưu file này vào thư mục wwwroot/MyWeb

Mở trình duyệt web lên gõ vào http://localhost/MyWeb/ten_file.aspx trang web bạn vừa soạn thảo sẽ được hiển thị

ASP.NET - Server Controls

Server controls là những tags được hiểu ở phía server HTML server controls

<form runat="server">

<a id="link1" runat="server">Visit W3Schools!</a> </form>

Web server controls

<asp:control_name id="some_id" runat="server" /> Validation server controls – For input validation <asp:control_name id="some_id" runat="server" />

ASP.NET - Event Handlers

Khai báo: <%

lbl1.Text="The date and time is " & now() %>

Gọi với câu lệnh:

<asp:label id="lbl1" runat="server" />

Page_Load Event:

<script runat="server"> Sub Page_Load

lbl1.Text="The date and time is " & now() End Sub

</script>

The Page.IsPostBack Property

<script runat="server"> Sub Page_Load

if Not Page.IsPostBack then

lbl1.Text="The date and time is " & now() end if

End Sub

lbl2.Text="Hello World!" End Sub

</script>

ASP.NET Web Forms

<form runat="server"> ...HTML + server controls </form>

Submitting a Form

<asp:Button id="id" text="label" OnClick="sub" runat="server" />

The TextBox Control

<html> <body>

<form runat="server"> A basic TextBox:

<asp:TextBox id="tb1" runat="server" /> <br /><br />

A password TextBox:

<asp:TextBox id="tb2" TextMode="password" runat="server" /> <br /><br />

A TextBox with text:

<asp:TextBox id="tb4" Text="Hello World!" runat="server" /> <br /><br />

A multiline TextBox:

<asp:TextBox id="tb3" TextMode="multiline" runat="server" /> <br /><br />

A TextBox with height:

<asp:TextBox id="tb6" rows="5" TextMode="multiline" runat="server" />

<br /><br />

A TextBox with width:

<asp:TextBox id="tb5" columns="30" runat="server" /> </form>

</body> </html>

The Button Control

<asp:Button id="b1" Text="Submit" runat="server" />

Một phần của tài liệu BAN NHAP 2 (Trang 32 -35 )

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×