You can find the HTML controls available in the Visual Basic toolbox when you click the HTML tab (as opposed to the Web Forms tab we've been using up to now). It's important to start off by noting that, although these controls are client HTML controls run in the browser by default, you can turn any HTML control into an HTML server control—whose events are handled back at the server—by right-clicking them in a Web page and selecting the Run As Server Control menu item.
When you add an HTML control to a Web form, by default, it's an HTML client control and only available for scripting in the Web page itself. To make it available to script code in the browser, you must give it an ID value, which you do with the (id) property in the Properties window; you can then refer to the control by ID in your script code.
When you turn the control into an HTML server control, on the other hand, Visual Basic gives it a default name, as it does with other controls you can access in Visual Basic code—although those names might be different than what you might expect. For example, the first text field gets the name Text1 (not TextBox1), the first radio button the name Radio1 (not RadioButton1), and so on. You can use this name to refer to the control in your Visual Basic code on the server; the control will have a Name property that holds this name. In other words, you use a control's ID in client code, and its Name in server-side code; for HTML server controls, these values are the same by default.
Some, but certainly not all, attributes of the HTML controls we'll work with become properties that you also can work with in Visual Basic code back on the server. You can, however, access all the HTML attributes of these controls using their Attributes property, which holds a collection of their HTML attributes, as we'll look at in this chapter. Keep in mind that not all attributes will be handled by all browsers. To see which attributes are handled in which browser, see the htmlref.html document on the CD-ROM. We'll see that these controls support fewer properties than the Web server controls we've been working with already, and which were specifically designed for Visual Basic .NET; the controls in this chapter are derived from the HtmlControl class, not the WebControl class.
Here's another thing to realize—these controls have no AutoPostBack property, which means that events have to wait to be processed until the user clicks a standard button or a Submit button, just as in other, standard Web pages you see on the Internet. So don't forget to add a Submit button to the pages you construct with these controls. You can create a Submit button with the Submit button tool in the toolbox—no additional code needed—so when the button is clicked, it'll send the page back to the server for processing. In addition, all values are stored as strings in HTML documents, so there's no data type safety here, and, because everything is available in the browser, there's a lot less security. On the other hand, using HTML controls is good when you want to handle a control both on the server and in the client, because you can write code for the same control in both locations.
You can see a number of the HTML server controls we'll discuss in this chapter in the HTMLControls example on the CD-ROM, which you see in Figure 19.1.