JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

HTML Server Control Classes

When you make an HTML control into a server control, Visual Basic uses the HTML Server Control classes to support that control in code. These classes include such classes as HtmlTextArea for HTML <textarea> controls, HtmlInputButton for HTML buttons created with <input type="button"> elements, HtmlInputText for HTML text fields created with <input type="text"> elements, and so on. Working with HTML server controls in Visual Basic really means working with objects of these support classes, which you can handle directly in Visual Basic code.

When you work with an HTML server control in the Visual Basic IDE, you'll see that its available properties are in lower case, indicating that these properties correspond directly to HTML attributes, and will appear in the .aspx page as you set them. Not all attributes have corresponding properties in the HTML server control classes, but many do, and they're supported by properties of these classes with the usual Visual Basic capitalization. For example, you can set the caption of an HTML server button at design time using the value property, which corresponds to the corresponding HTML <input> element's value attribute. But at run time, back on the server, this attribute is supported by the HtmlInputButton class's Value property. Because we're working with an object of the HtmlInputButton class on the server, the capitalization of property names in server code adheres to the Visual Basic standard, so don't get confused if you see references to both a value property (used in an element at design time or in client-side code) and a Value property (used in the element's corresponding object in server-side code).

It's important to realize that there is not a complete one-to-one correspondence with the HTML Server Control classes and the actual HTML controls you see in the HTML toolbox. For example, the HtmlInputButton class is used not just for buttons, but also for reset buttons (which sets the value in HTML controls back to their default values), as well as submit buttons. These buttons are all created using an HTML <input> element, and they differ only in the setting of the type HTML attribute in that element (a standard button uses <input type="button">, a reset button uses <input type="reset">, and a submit button uses <input type="submit">).

You can find the HTML server control classes in Table 19.1.

Table 19.1: HTML server control classes.


Does this


Creates an HTML form.


Creates an HTML text field. (You also can use this control to create password fields).


Creates an HTML text area (two-dimensional text field).


Creates an <a> element for navigation.


Creates an HTML button using the <button> element.


Creates an HTML button using the <input> element.


Creates an HTML button that displays images.


Creates an HTML select control.


Creates an HTML <img> element.


Creates an HTML hidden control.


Creates an HTML checkbox.


Creates an HTML radio button.


Creates an HTML table.


Creates an HTML row in a table.


Creates an HTML cell in a table.


Creates an HTML file upload control.


Creates a basic control for an HTML element.


Note that there's an HtmlForm class in Table 19.1. HTML programmers know that HTML controls must be in an HTML form to be sent back to the server. However, when creating a Web form in the Visual Basic IDE, you don't have to create the HTML form explicitly—Visual Basic does that as soon as you add input controls to the form.

I'll look at these various classes in more detail and how to work with them in code in this chapter. You can find the notable properties, methods, and events of these classes in the Immediate Solutions section of this chapter. As mentioned, the HTML classes you see in Table 19.1 are not based on the WebControl class we've seen in previous chapters, but on the HtmlControl class. I'll start with that.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor