Working in Source and Split Views to Build a One-Page Web Application
(Page 1 of 4 )
Welcome to the third part of a five-part article series on building web applications with ASP.NET. In this part, we take a closer look at working in the Design view of this application development framework. This article is excerpted from chapter two of
Murach's ASP.NET 3.5 Web Programming with VB 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774472).
Common properties for web server controls
The first table in figure 2-9 presents the properties for web server controls that you’re most likely to use as you develop web forms. If you’ve worked with Windows controls, you’ll notice that many of the properties of the web server controls provide similar functionality. For example, you use the ID property to name a control that you need to refer to in code, and you can use the Text property to determine what’s displayed in or on the control. However, the AutoPostBack, CausesValidation, EnableViewState, and Runat properties are unique to web server controls. Since you already know the purpose of the Runat property, I’ll focus on the other three properties here.
The AutoPostBack property determines whether the page is posted back to the server when the user changes the value of the control. Note that this property is only available with certain controls, such as check boxes, drop-down lists, and radio buttons. Also note that this property isn’t available with button controls. That’s because button controls always either post a page back to the server or display another page.
The CausesValidation property is available for button controls and determines whether the validation controls are activated when the user clicks the button. This lets you check for valid data before the page is posted back to the server. You’ll learn more about validation controls a few figures from now.
The EnableViewState property determines whether a server control retains its property settings from one posting to the next. For that to happen, the EnableViewState property for both the form and the control must be set to True. Since that’s normally the way you want this property set, True is the default.
The second table in this figure lists four more properties that are commonly used with drop-down lists and list boxes. However, you don’t need to set these at design time. Instead, you use them when you write the Visual Basic code for the code-behind file. For instance, you use the Items collection to add, insert, and remove ListItem objects. And you use the SelectedValue property to retrieve the value of the currently selected item. You’ll learn more about these properties when you review the code-behind file for the Future Value form.
Common web server control properties
Property | Description |
AutoPostBack | Determines whether the page is posted back to the server when the value of the control changes. Available with controls such as a check box, drop-down list, radio button, or text box. The default value is False. |
CausesValidation | Determines whether the validation that’s done by the validation controls occurs when you click on the button, link button, or image button. The default value is True. (You’ll learn how to use two common validation controls later in this chapter.) |
EnableViewState | Determines whether the control maintains its view state between HTTP requests. The default value is True. |
Enabled | Determines whether the control is functional. The default value is True. |
Height | The height of the control. |
ID | The name that’s used to refer to the control. |
Runat | Indicates that the control will be processed on the server by ASP.NET. |
TabIndex | Determines the order in which the controls on the form receive the focus when the Tab |
| key is pressed. |
Text | The text that’s displayed in the control. |
ToolTip | The text that’s displayed when the user hovers the mouse over the control. |
Visible | Determines whether a control is displayed or hidden. |
Width | The width of the control. |
Common properties of drop-down list and list box controls
Property | Description |
Items | The collection of ListItem objects that represents the items in the control. Although you can set the values for these list items at design time, you normally use code to add, insert, and remove the items in a drop-down list or list box. |
SelectedItem | The ListItem object for the currently selected item. |
SelectedIndex | The index of the currently selected item. If no item is selected in a list box, the value of this property is -1. |
SelectedValue | The value of the currently selected item. |
Note
--------------------------------------------Figure 2-9 Common properties for web server controls
Next: How to work in Source and Split views >>
More ASP.NET Articles
More By Murach Publishing
|
This article is an excerpt from chapter two of Murach's ASP.NET 3.5 Web Programming with VB 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774472). Check it out today at your favorite bookstore. Buy this book now.
|
|