1. Trang chủ
  2. » Công Nghệ Thông Tin

Asp.net slide3

29 239 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Session 5 Web Server Controls
Trường học Standard University
Chuyên ngành Computer Science
Thể loại Bài tập
Năm xuất bản 2023
Thành phố Hanoi
Định dạng
Số trang 29
Dung lượng 397,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Asp.net slide

Trang 1

Session 5

Web Server Controls

Trang 2

 The @ Page directive is used to specify attributes that affect the

code in the aspx page.

 The <script> section is where most of the code for providing the required functionality is written.

 There are two types of server controls:

 HTML Controls

 Web Controls

 All event procedures receive two arguments from the events:

 The event sender

 The class instance that holds data for the event

 The _VIEWSTATE control is a hidden control that is added to the form when the form is submitted to the server.

 It is possible to check whether a aspx page is posted back to the server, with the help of the IsPostBack property of the page.

Trang 3

Review Contd…

 ASP.NET has several built-in objects that are used to provide the

required functionality in an ASP.NET application They are the following:

The base directory is called the virtual root, and the directory in which

we store the application files is called the virtual directory.

 The Request object corresponds to the request message of the HTTP protocol, and the Response object corresponds to the response

message of the HTTP protocol.

 The Form.Get method of the Request object is used to retrieve the data submitted by the user.

 The Redirect method of the Response object is used to redirect the user to another page.

Trang 4

 Explain Web Controls

 Explain why controls are objects

 Use Controls for Text Entry

 Use Controls for Control Transfer

 Use Controls for Selection

 Discuss Rich Controls

Trang 5

Web Controls

ASP.NET Controls

Intrinsic

List

Rich

Validation

Trang 6

Web Controls as Objects

 Like objects, web controls possess methods and properties, and respond to events

 It is possible to set the properties and call the

methods of the web controls once they are

included onto the web page

 Server-side code can be written for the web

control to respond to events that occur on the

client-side

Trang 7

Web Controls as Objects - Example

<html>

<script language="C#" runat ="server" >

void Button1click(Object Src, EventArgs E){

lblMessage.Text =Src.ToString();

btnButton1.Enabled = false;

btnButton2.Visible = true;

}void Button2click(Object Src, EventArgs E){

Trang 8

Web Controls as Objects - Example

<asp:button id="btnButton1" type = submit text= "Click

me to know who I am" OnClick="Button1click" runat = "server" />

<asp:button id="btnButton2" type = submit text=

"Clear the label" visible=false OnClick="Button2click" runat = "server" /

Trang 9

Web Controls as Objects - Output

Output of Example 1 Before clicking the button

Output of Example 1

After clicking the button

Trang 11

Text Entry - Intrinsic Control

Trang 12

Posting data back

to the server

Navigate between the pages

Save or access data from the server

Control Transfer - Intrinsic Control

Trang 13

Control Transfer

Trang 14

<asp:checkbox id="chkbx1" Text="Select Me" runat="server"/>

Intrinsic Control: Selection

<asp:CheckBoxList id="CheckBoxList1" runat="server">

<asp:ListItem Value="Maths">Maths</asp:ListItem>

<asp:ListItem Value="Science">Science</asp:ListItem>

<asp:ListItem Value="English">English</asp:ListItem>

<asp:ListItem Value="Computers">Computers</asp:ListItem>

</asp:CheckBoxList>

Trang 15

Intrinsic Control: Selection

<asp:radiobutton id ="radbt1" Text =" Radio Button no 1"

Trang 16

<asp:listbox id="lstbx1" SelectionMode=”Single”

runat="server"/>

Intrinsic Control: Selection

<asp:RadioButtonList id="RadioButtonList1" runat="server">

Trang 17

ArrayList arrlist= new

<asp:listbox id="lbs" runat="server">

<asp:ListItem> One </asp:ListItem>

<asp:ListItem> Two </asp:ListItem>

<asp:ListItem> Three </asp:ListItem>

</asp:listbox>

<asp:dropdownlist id= "ddl"

runat="server" >

<asp:ListItem> One </asp:ListItem>

<asp:ListItem> Two </asp:ListItem>

<asp:ListItem> Three </asp:ListItem>

</asp:dropdownlist>

Intrinsic Control: Selection –

Methods to populate data

Trang 18

<asp:panel id="panel1" Visible="False" runat="server" >

<asp:textbox id="OldPwd" textmode="password"

runat="server"/>

<asp:textbox id="NewPwd" textmode="password"

runat="server"/>

</asp:panel>

 Container controls can contain other controls

 One of the main uses of container controls, is that the

visibility of a group of controls can be changed at one

point by placing them in a container control, and

setting the property of the container control

 Container controls can contain other controls

 One of the main uses of container controls, is that the

visibility of a group of controls can be changed at one

point by placing them in a container control, and

setting the property of the container control

Container

Trang 19

Used for changing the

advertisements on

the web pages

Gives full functionality of

a calendar

Rich Controls

Trang 20

Absolute or relative Url of the image file

Target website after clicking the Ad

Text that will be displayed when the mouse is rolled over the

image

Category assigned to the ad

Priority of the advertisement in the schedule of rotation

AdRotator

Trang 21

AdRotator – Output

Trang 22

Calendar Control

 Simple to use, and gives us the full functionality

of a calendar

 The calendar can be created and formatted to

suit the look and feel of the web page

Trang 24

Calendar Control - Example

<html>

<script language="C#" runat ="server" >

void date_changed(Object sender,EventArgs e)

Trang 25

Calendar Control - Example

Trang 26

Calendar Control - Example

Trang 27

Calendar Control - Output

Trang 29

Summary Contd…

 There are four controls in ASP.NET that can be used to navigate

between pages, or transfer control to a specified page:

 ASP.NET provides container controls, that is, the controls that

can contain other controls.

 ASP.NET provides two rich controls:

 AdRotator Control

 Calendar Control

Ngày đăng: 15/11/2012, 14:44

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN