Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The Web Forms Model 23 If the tag does contain namespace information, it is acceptable as long as the namespace is <asp> or a namespace explicitly associated with the tag name using an @Register directive. If the namespace is unknown, a compile error occurs. ASP.NET Server Controls There are basically two families of ASP.NET server controls. They are HTML server controls and Web server controls. System.Web.UI.HtmlControls is the namespace of HTML server controls. System.Web.UI.WebControls groups all the Web server controls. HTML server controls are classes that represent a standard HTML tag supported by most browsers. The set of properties of an HTML server control matches exactly the set of attributes of the corre- sponding tag. The control features properties such as InnerText , InnerHtml , Style , and Value and collections such as Attributes . Instances of HTML server controls are automatically created by the ASP.NET runtime each time the corresponding HTML tag marked with runat="server" is found in the page source. Web server controls are controls with more features than HTML server controls. Web server controls include not only input controls such as buttons and textboxes, but also special-purpose controls such as a calendar, an ad-rotator, a drop-down list, and a data grid. Web server controls also include components that closely resemble some HTML server controls. Web server controls, though, are more abstract than the corresponding HTML server controls in that their object model doesn't nec- essarily reflect the HTML syntax. For example, let's compare the HTML server text control and the Web server TextBox control. The HTML server text control has the following markup: <input runat="server" id="FirstName" type="text" value="Dino" /> The Web server TextBox control has the following markup: <asp:textbox runat="server" id="FirstName" text="Dino" /> Both controls generate the same HTML code. However, the programming interface of the HTML server text control matches closely that of the HTML <input> tag, while methods and properties of the Web server TextBox control are named in a more abstract way. For example, to set the content of an HTML server text control, you must use the Value property because Value is the corresponding HTML attribute name. If you work with the Web server TextBox control, you must resort to Text . With very few exceptions (which I'll discuss in Chapter 3), using HTML server controls or Web server controls to represent HTML elements is only a matter of preference. Migrating from ASP to ASP.NET In the past five years, one million developers all over the world have chosen ASP as the development platform of choice to build Web applications. You can bet that with such a huge base of installed applications, the problem of ensuring backward compatibility between ASP and ASP.NET has been taken very seriously. The result is that ASP and ASP.NET applications can run side by side on an IIS Web server without any form of interference occurring. In addition, and in spite of the radical changes in the underlying architecture and implementation, a significant portion of existing ASP pages can just be renamed as .aspx files and will continue working (even a bit faster) and be man- aged by a different IIS module. Does this really mean you can migrate ASP applications to ASP.NET simply by renaming files? Well, not exactly. As always, code migration is a delicate art that becomes impracticable when huge architectural differences exist between the starting and ending points. ASP.NET is designed to make migration easier, but a migration plan is still needed and a 100 percent pure ASP.NET solution is needed to be really effective.