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

Tài liệu Working with controls ppt

37 383 0

Đ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

Định dạng
Số trang 37
Dung lượng 2,07 MB

Nội dung

aspnet aspnet Working with controls Working with controls Hà Đồng Hưng Giới thiệu VMWare Workst ation 2 Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls Giới thiệu VMWare Workst ation 3 Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls Giới thiệu VMWare Workst ation 4 Server controls vs HTML controls Feature Server controls HTML controls Server events Trigger control-specific events on the server. Can trigger only page-level events on server (post-back) State Management Data entered in a control is maintained across requests. Data is not maintained; must be saved and restored using page- level scripts Adaptation Automatically detect browser and adapt display as appropriate. No automatic adaptation; must detect browser in code or write for least common denominator Properties The .NET Framework provides a set of properties for each control. Properties allow you to change the control' s appearance and behavior within server- side code. HTML attributes only Giới thiệu VMWare Workst ation 5 Using HTML controls ??? Use HTML controls for the following reasons: • Migration from earlier versions of ASP. • Not all controls require server-side events or state management. – This is particularly true when doing data binding. Bound items are usually refreshed from the data source with each request, so it is more efficient not to maintain state information for bound controls.  use HTML controls or turn off state management for bound server controls. • You have complete control over what is rendered with HTML controls. Giới thiệu VMWare Workst ation 6 Difference in HTML tags • Server control: – <asp:controlname id="some_id" runat="server"/> • HTML control: – HTML tags • Examples: – <asp:TextBox id="txtText" runat="server"></asp:TextBox> – <INPUT type="text" id="textfield1"> – <asp:Button id="btnShow" runat="server" Text="Show"></asp:Button> – <INPUT type="button" value="Show"> Giới thiệu VMWare Workst ation 7 Server Controls and HTML Controls Server controls HTML controls Display text Label, TextBox, Literal Label, Text Field, Text Area, Password Field Display tables Table, DataGrid Table Select from list DropDownList, ListBox, DataList, Repeater List Box, Dropdown Perform commands Button, LinkButton, ImageButton Button, Reset Button, Submit Button Set values CheckBox, CheckBoxList, RadioButton, RadioButtonList Checkbox, Radio Button Display images Image, ImageButton Image Navigation Hyperlink none (use <a> tags in text) Giới thiệu VMWare Workst ation 8 Server Controls and HTML Controls Group controls Panel, Placeholder Flow Layout, Grid Layout Work with dates Calendar none Display ads AdRotator none Display horizontal rules Literal Horizontal Rule Get filenames from client none File Field Store data on page (provided by state management) Input Hidden Validate data RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator,ValidationSummary none (use page- level) Giới thiệu VMWare Workst ation 9 Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls Giới thiệu VMWare Workst ation 10 Simple controls Label, Buttons, TextBox - HTML tags • Label – <asp:Label id="Label1" runat="server">Please input text</asp:Label> • Buttons (Button, LinkButton, ImageButton) – <asp:Button id="Button1" runat="server" Text="Button"></asp:Button> – <asp:LinkButton id="LinkButton1" runat="server">LinkButton</asp:LinkButton> – <asp:ImageButton id="ImageButton1" runat="server"></asp:ImageButton> • TextBox – <asp:TextBox id="TextBox1" runat="server"></asp:TextBox> [...]... Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validating controls • Other controls Simple Data Binding Data Binding • Binding data with all common controls (except DataList,... property to False Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls Validation controls • Validation controls check the validity of data... txtPassword.ReadOnly = True End If Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls List Controls ListBox, DropDownList, Table Control Use... ClientValidationFunction property Objectives • Server controls vs HTML controls • Simple controls – Label, Buttons (Button, LinkButton, ImageButton), TextBox – List Controls (ListBox, DropDownList, Table,DataGrid, DataList, Repeater ) • Data Binding with controls – Simple Data Binding – Data Binding with Database • Validation controls • Other controls Other controls • Getting and Setting Values – RadioButton,... Response.Write("Checkbox1 is CHECKED") End If End Sub • All RadioButtons must have the same GroupName Other controls: Panel • Draw the controls on the Web form • Drag the controls on to the Panel control in the order you want them displayed • Use Enter and Space to place the controls where you want them to appear Other controls: Graphics and Advertisements • As a background – Use the Background property of the Web... text in a simple scrollable list format DropDownList Display read-only text in a simple drop-down list format Table Display text and controls in columns and rows Table controls allow you to dynamically build tables in code using TableRows and TableCells collections List Controls: HTML tags • ListBox – • DropDownList – . aspnet Working with controls Working with controls Hà Đồng Hưng Giới thiệu VMWare Workst ation 2 Objectives • Server controls vs HTML controls • Simple controls. Database • Validation controls • Other controls Giới thiệu VMWare Workst ation 4 Server controls vs HTML controls Feature Server controls HTML controls Server

Ngày đăng: 11/12/2013, 17:15

TỪ KHÓA LIÊN QUAN

w