Tải bản đầy đủ - 0 (trang)
Chapter 12. User Assistance and Accessibility

Chapter 12. User Assistance and Accessibility

Tải bản đầy đủ - 0trang

WebServerControls

Webservercontrolsprovideahigherlevelofabstractionthan

HTMLservercontrolsbecausetheirobjectmodelmatches

closelywiththe.NETFrameworkratherthanmatchingwiththe

requirementsofHTMLsyntax.

TheWebservercontrolshaveseveraladvancedfeatures,

including

Webservercontrolsprovidearichobjectmodelthatclosely

matcheswiththerestofthe.NETFramework.

SomeWebservercontrolsprovidericherfunctionality,such

astheCalendarcontrol,AdRotatorcontrol,andsoon,not

availablewithHTMLcontrols.

Webservercontrolshaveadvancedfeaturessuchas

automaticbrowserdetection,automaticpostback,and

eventbubbling.

BecauseWebservercontrolsarespecificallydesignedtointegratewell

withtheASP.NETprogrammingmodel,Exam70-315islikelytofocus

moreonWebservercontrolsthanonHTMLandHTMLservercontrols.



Webservercontrolsaredeclaredincodeexplicitlybyprefixing

theclassnameoftheWebservercontrolwiththenamespace

aspandseparatingbothwithacolon(:),aswellasincluding

therunat="server"attributeinitsdefinition.Forexample,a

LabelWebservercontrolcanbedeclaredincodeas



.

MostWebservercontrolsderivetheirfunctionalityfromthe

WebControlclassoftheSystem.Web.UI.WebControls

namespace.

Table3.1listssomeoftheimportantpropertiesinheritedby

WebservercontrolsthatderivefromtheWebControlclass.

Table3.1.ImportantPropertiesofthe

System.Web.UI.WebControls.WebControlClass

Property



Description



AccessKey



Representsthesinglecharacterkeyboardshortcutkeyforquick

navigationtotheWebservercontrol.ThefocusismovedtotheWeb

servercontrolwhentheAltkeyandthekeyassignedtothisproperty

arepressed.



BackColor



SpecifiesthebackgroundcoloroftheWebservercontrol.



BorderColor



SpecifiesthebordercoloroftheWebservercontrol.



BorderStyle



SpecifiestheborderstyleoftheWebservercontrol.Thepossiblevalues

aredefinedintheBorderStyleenumerationvalues;theyareDotted,

Dashed,Double,Inset,NotSet,None,OutSet,Groove,Solid,and

Ridge.



BorderWidth



SpecifiestheborderwidthoftheWebservercontrol.



Controls



RepresentsthecollectionofcontrolsaddedtotheWebservercontrolas

childcontrols.TheWebControlclassinheritsthispropertyfromthe

Controlclass.



CssClass



RepresentstheCSSclassinwhichtheWebservercontrolisrendered.



Enabled



IndicateswhethertheWebservercontrolisenabledtoreceivefocus.



EnableViewState IndicateswhetherviewstateisenabledfortheWebservercontrol.The

WebControlclassinheritsthispropertyfromtheControlclass.

Font



SpecifiesaFontInfoobjectthatrepresentsthefontpropertiesofa



Webservercontrol.

ForeColor



SpecifiesthecoloroftextintheWebservercontrol.



Height



SpecifiestheheightoftheWebservercontrol.



ID



SpecifiesanidentifierfortheWebservercontrol.TheWebControl

classinheritsthispropertyfromtheControlclass.



Parent



RepresentstheparentcontroloftheWebservercontrol.The

WebControlclassinheritsthispropertyfromtheControlclass.



Style



SpecifiesthecollectionofCSSpropertiesappliedtotheWebserver

control.



TabIndex



SpecifiesthetaborderofaWebservercontrol.Anegativevalue

removesthecontrolfromthetaborder.



ToolTip



Specifiesthepop-uptextdisplayedbytheWebservercontrolwhenthe

mousehoversoverit.



Visible



IndicateswhethertheWebservercontrolisvisibleontherendered

page.TheWebControlclassinheritsthispropertyfromtheControl

class.



Width



SpecifiesthewidthoftheWebservercontrol.



CommonWebServerControls

Thissectiondiscussessomesimplebutcommonlyusedcontrols

availableintheVisualStudio.NETtoolbox.Thesecontrolsare

simplebecausetheyareusuallyrenderedassingleHTML

elementsandhaveonlyafewproperties.Laterinthischapter,

youwilllearnaboutsomeadvancedcontrolsthatprovide

myriadpropertiesandrenderbigchunksofHTMLcode.



LabelControls



ALabelcontrolisusedtodisplayread-onlyinformationtothe

user,labelothercontrols,andprovidetheuserwithanyuseful

messagesorstatistics.Itexposesitstextcontentthroughthe

Textproperty,whichcanbeusedtomanipulateitstext

programmatically.ThecontrolisrenderedasaHTML

elementontheWebbrowser.



TextBoxControls

ATextBoxcontrolprovidesanareatheusercanusetoinput

text.DependingonhowyousetthepropertiesofthisWeb

servercontrol,youcaneitheruseitformultilinetextinputor

useitlikeapasswordboxthatmasksthecharactersenteredby

theuser.Thus,thisservercontrolcanberenderedasthree

typesofHTMLelements:,
type="password">,and