Download presentation
Presentation is loading. Please wait.
Published byNicholas Atkinson Modified over 8 years ago
1
Types of Server Controls, HTML Server Controls, Web Controls, List Controls, Input Validation Controls, Rich Controls
2
2 ASP.NET server controls are a fundamental part of the ASP.NET architecture. Server controls are classes in the.NET Framework that represent visual elements on a web form Some of these classes are relatively straightforward and map closely to a specific HTML tag. Other controls are much more ambitious abstractions that render a more complex representation
3
3 ASP.NET offers many different server controls. HTML server controls: Classes that wrap the standard HTML elements. Two examples include HtmlAnchor (for the tag) and HtmlSelect (for the tag) Can turn any HTML tag into a server control If there isn’t a direct corresponding class, ASP.NET will simply use the HtmlGenericControl class. simply add the runat="server" attribute to turn into server control
4
4 Web controls: Duplicate the functionalities of the basic HTML elements But have a more consistent and meaningful set of properties and methods that make it easier for the developer to declare and access them Some examples are the HyperLink, ListBox, and Button controls. More special types of web controls are also available.
5
5 Rich controls : Advanced controls have the ability to generate a large amount of HTML markup and even client-side JavaScript to create the interface. Examples include the Calendar, AdRotator, and TreeView controls.
6
6 Validation controls: Set of controls allows you to easily validate an associated input control against several standard or user-defined rules. Can specify that the input can’t be empty, that it must be a number If validation fails, you can prevent page processing or allow these controls to show inline error messages in the page.
7
7 Data controls Include sophisticated grids and lists that are designed to display large amounts of data, with support for advanced features such as editing, sorting. Includes the data source controls that allow you to bind to different data sources declaratively, without writing extra code.
8
8 Navigation controls Designed to display site maps and allow the user to navigate from one page to another. Login controls Support forms authentication, an ASP.NET model for authenticating users against a database and tracking their status Can use these controls to get prebuilt, customizable login pages, password recovery, and user-creation wizards.
9
9 All server controls derive from the base Control class in the System.Web.UI namespace.
10
10 Most commonly used members of the Control class PropertyDescription ClientIDIdentifier of the control ControlsReturns the collection of child controls EnableViewStateReturns or sets a Boolean value related to view state of control IDReturns or sets the identifier of the control PageReturns a reference to the page object that contains the control ParentReturns a reference to the control’s parent VisibleReturns or sets a Boolean value indicating whether the control should be Rendered
11
11 Defined in the namespace System.Web.UI.HtmlControls
12
12 HTML server controls on the page is the same as what you use for normal static HTML tags, with the addition of the runat="server“ attribute. Complete this slide – page 120 Tag Declaration.NET ClassSpecific Members HtmlAnchorHRef, Target, Title, Name, ServerClick event HtmlButtonCausesValidation, ValidationGroup, ServerClick event HtmlFormEnctype, Method, Target, DefaultButton, DefaultFocus HtmlImageAlign, Alt, Border, Height, Src, Width
13
13 Tag Declaration.NET ClassSpecific Members HtmlInputButtonType, Value, CausesValidation, ValidationGroup, ServerClick event HtmlInputResetType, Value HtmlInputSubmitType, Value, CausesValidation, ValidationGroup, ServerClick event HtmlInputCheckBoxChecked, Type, Value, ServerClick event
14
14 Tag Declaration.NET ClassSpecific Members HtmlInputFileAccept, MaxLength, PostedFile, Size, Type, Value HtmlInputHiddenType, Value, ServerChange event HtmlInputImageAlign, Alt, Border, Src, Type, Value, CausesValidation, ValidationGroup, ServerClick event HtmlInputRadioButtonChecked, Type, Value, ServerChange event
15
15 Tag Declaration.NET ClassSpecific Members HtmlInputTextMaxLength, Type, Value, ServerChange event HtmlInputPasswordMaxLength, Type, Value, ServerChange event HtmlSelectMultiple, SelectedIndex, Size, Value, DataSource, DataTextField, DataValueField, Items (collection), ServerChange event, HtmlTableAlign, BgColor, Border, BorderColor, CellPadding, CellSpacing, Height, NoWrap, Width, Rows (collection)
16
16 Tag Declaration.NET ClassSpecific Members HtmlTableCellAlign, BgColor, Border, BorderColor, ColSpan, Height, NoWrap, RowSpan, VAlign, Width HtmlTableRowAlign, BgColor, Border, BorderColor, Height, VAlign, Cells (collection) HtmlTextAreaCols, Rows, Value, ServerChange event Any other HTML tag with the runat="server" attribute HtmlGenericControlNone
17
17 HTML server controls provide a sparse event model with two possible events: ServerClick and ServerChange. The ServerClick event is simply a click that is processed on the server side The ServerChange event responds when a change has been made to a text or selection control
18
18 EventControls That Provide It ServerClickHtmlAnchor, HtmlButton, HtmlInputButton, HtmlInputSubmit,HtmlInputReset, HtmlInputImage ServerChangeHtmlInputText, HtmlInputCheckBox, HtmlInputRadioButton, HtmlInputHidden, HtmlSelect, HtmlTextArea HTML Control Events
19
19 Portion of the Inheritance Hierarchy for Web Controls
20
20 HTML server controls provide a relatively fast way to migrate to ASP.NET ASP.NET provides a higher-level web control model web controls are defined in the System.Web.UI.WebControls namespace Web controls also enable additional features, such as automatic postback Extended controls don’t just map a single HTML tag but instead generate more complex output made up of several HTML tags and JavaScript code
21
21 All the web controls inherit from the WebControl class. The WebControl class also derives from Control.
22
22 PropertyDescription AccessKeyReturns or sets the keyboard shortcut that allows the user to quickly navigate to the control. BackColorReturns or sets the background color BorderColorReturns or sets the border color BorderStyleOne of the values from the BorderStyle enumeration, including Dashed, Dotted, Double, Groove, Ridge, Inset, Outset, Solid, and None.
23
23 PropertyDescription BorderWidthReturns or sets the border width. CssClassReturns or sets the CSS style to associate with the control. The CSS style can be defined in a section at the top of the page or in a separate CSS file referenced by the page. EnabledReturns or sets the control’s enabled state. If false, the control is usually rendered grayed out and is not usable. FontReturns an object with all the style information of the font used for the control’s text.
24
24 PropertyDescription ForeColorReturns or sets the foreground color. HeightReturns or sets the control’s height. TabIndexA number that allows you to control the tab order. This property is supported only in Internet Explorer 4.0 and higher. TooltipDisplays a text message when the user hovers the mouse above the control. Many older browsers don’t support this property. WidthReturns or sets the control’s width.
25
25 ASP.NETGenerated HTMLKey Members or Text, CausesValidation, PostBackUrl,ValidationG roup, Click event AutoPostBack, Checked, Text, TextAlign, CheckedChanged event FileBytes, FileContent, FileName, HasFile, PostedFile, SaveAs() Value
26
26 ASP.NETGenerated HTMLKey Members... ImageUrl, NavigateUrl, Target, Text AlternateText, ImageAlign, ImageUrl CausesValidation, ValidationGroup, Click event HotSpotMode, HotSpots (collection), AlternateText, ImageAlign, ImageUrl
27
27 ASP.NETGenerated HTMLKey Members... Text, AssociatedControlID Text, CausesValidation, Validation- Group, Click event... BackImageUrl, DefaultButton, GroupingText, HorizontalAlign, Scrollbars, Wrap AutoPostBack, Checked, GroupName, Text, TextAlign, CheckedChanged event
28
28 ASP.NETGenerated HTMLKey Members... BackImageUrl, CellPadding, CellSpacing, GridLines, HorizontalAlign, Rows (collection)... ColumnSpan, HorizontalAlign, RowSpan, Text, VerticalAlign, Wrap... Cells (collection), HorizontalAlign, VerticalAlign or... AutoPostBack, Columns, MaxLength, ReadOnly, Rows, Text, TextMode, Wrap, TextChanged event
29
29 Differences: The control is declared using its class name (TextBox) instead of the HTML tag name (input). The default content is set with the Text property, instead of a less obvious Value attribute. The style attributes (colors, width, and font) are set by direct properties, instead of being grouped together in a single style attribute.
30
30 Server-side events work in much the same way as the server events of the HTML server controls. Web controls support the AutoPostBack feature. Example application adds a new entry to a list control every time one of the events occurs
31
31 The list controls are specialized web controls that generate list boxes, drop-down lists, and other repeating controls. Can be either bound to a data source Allow the user to select one or more items
32
32 ControlDescription A drop-down list populated by a collection of objects.In HTML, it is rendered by a tag with the size="1" attribute. A list box list populated by a collection of objects. In HTML, it is rendered by a tag with the size="x" attribute, where x is the number of visible items. Its items are rendered as check boxes. Like the, but the items are rendered as radiobuttons. A static bulleted or numbered list. In HTML, it is rendered using the or tags( Can use to create list of hyperlinks).
33
33 The selectable list controls include the DropDownList, ListBox, CheckBoxList, and RadioButtonList controls. RadioButtonList and CheckBoxList render multiple option buttons or check Boxes.
34
34 The BulletedList control is the server-side equivalent of the (unordered list) or PropertyDescription BulletStyleDetermines the type of list BulletImageUrlIf the BulletStyle is set to CustomImage, this points to the image. FirstBulletNumberthis sets the first value DisplayModeDetermines whether the text of each item is rendered as text or a hyperlink
35
Rich controls provide an object model that has a complex HTML representation and also client side JavaScript. Examples:- AdRotator Calendar
36
Steps for using AdRotator Define the XML schedule file with tag and its properties defined Specify Advertisement file value un AdRotator definition in Page design view. AdCreated event can be trapped
37
TAG Description The image that will be displayed. The link will be followed if user clicks the banner. The text will be displayed in place of picture. A new ad is selected whenever the Web page refreshes. An impression attribute can be assigned to each ad. It controls how often an ad is selected relative to other ad in ad file
38
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.