370 likes | 1.58k Views
ASP.NET Web Server Controls. Basic Web Server Controls. Overview. The ASP.NET page framework includes a number of built-in server controls that are designed to provide a more structured programming model for the Web. These controls provide the following features : Automatic state management.
E N D
ASP.NET Web Server Controls Basic Web Server Controls
Overview • The ASP.NET page framework includes a number of built-in server controls that are designed to provide a more structured programming model for the Web. These controls provide the following features: • Automatic state management. • Simple access to object values without having to use the Request object. • Ability to react to events in server-side code to create applications that are better structured. • Common approach to building user interfaces for Web pages. • Output is automatically customized based on the capabilities of the browser.
ASP.NET Web Server Controls • Server controls are added to a page, and programmers write code to handle events raised by users’ interaction with the controls at runtime. • Built in Server controls are divided into two groups: • HTML controls • Reside in the System.Web.UI.HTMLControls namespace • Map 1-to-1 with the standard HTML elements • Web controls • Reside in the System.Web.UI.WebControlsnamespace • All Web controls use the prefix asp
Web Server Control Categories • Basic Web Controls • Commonly used user input controls such as labels, text boxes, and drop-down lists • Validation Controls • used to validate the values that are entered into other controls of the page • perform client-side validation, server-side validation, or both • List Controls • support binding to collections • display rows of data in a customized format • Rich Controls • task-specific controls with rich functionality • Examples: AdRotatorand Calendar controls
Basic Web Server Controls • Label • TextBox • CheckBox • RadioButton • DropDownList • Image • Panel • Button • HyperLink • ImageButton • LinkButton • Literal • PlaceHolder • Table • TableCell • TableRow
Using Web Server Controls • Add server control to page • Set server control properties • Add event handler if needed
Web Server Control Properties • The System.Web.UI.WebControls.WebControl base class contains all of the common properties. Most of the Web server controls derive from this class. • See the next slide for a list of common properties.
Event Model • One of the key features of ASP.NET is that it uses an event-based programming model. • An event handler is a method that determines what actions are performed when an event occurs, such as when the user clicks a button or selects an item from a list. • When an event is raised, the handler for that specific event is executed
Event Handlers • In the .NET Framework, all event handlers have a specific method signature, that is, a specific return type and parameters. • Event handlers are always void methods. • Event handlers always accept two parameters: • an object parameter • an EventArgsparameter (or a subclass of EventArgs, such as CommandEventArgs or ImageClickEventArgs).