Composite Custom Control

A composite custom control shares many of the benefits of user controls, and at the same time offers the benefits of normal custom controls. If you're a developer for an internal Internet or intranet site, the functional difference between a user control and a composite custom control isn't that great. However, if you need to distribute a component to other groups within your organization or if you're a third-party vendor planning to sell a component, the composite custom control offers...

Enhancing Design Time Support

Referring back to Figure 6-7, notice the selected control, which reads 'RequiredTextBox Designer'. By default, a control in design mode will show just what would be displayed by a call to RenderControl. If this call would result in nothing being displayed, Visual Studio .NET will instead display the type and ID of the control, something like 'RequiredTextBox RequiredTextBox1'. If you want to create your own display in the designer, you do have a few alternatives. The usual way to display the...

More Complicated Custom Control

Our simple CenteredLabel custom control example was a good starting place for learning about custom controls. However, it doesn't even begin to touch on what you can achieve using custom controls. In the next example, we'll create a more complicated custom control to handle a more common scenario. Whenever you're laying out a Web Form, you'll almost certainly want to lay out text boxes with labels that describe the required entry. A great number of variables are inherent within this situation....

Firing Postbacks from a Custom Control

Some controls support the AutoPostBack attribute and so can cause a postback to occur after a change in the data. Unfortunately, the custom controls you design might not descend from a control that supports AutoPostBack. Fortunately, there is a solution. The Page class exposes a method named GetPostBackEventReference that emits client-side script that allows a control to cause a postback. The resulting JavaScript is nearly identical to the JavaScript in Listing 7-3. Listing 7-4 shows a Visual...

The httpHandlers Section

The httpHandlers section maps incoming requests to the appropriate IHttpHandler or IHttpHandlerFactory class, according to the URL and the HTTP verb requested. Note When I talk about HTTP verbs, I mean the keywords used to specify what action the Web server should take. If you're an HTML developer, the most common HTTP verbs will be POST and GET. When you create an HTML form, you have these two options for the METHOD attribute of the lt FORM gt tag. When GET is specified, any form values are...

Repeater Control Basics

The Repeater control acts in many ways like the DataGrid control, but it gives you greater flexibility at the individual column level. There are no restrictions on how many or how few columns you display, and technically, you don't have to use a tabular view at all. The information displayed for each record bound to the Repeater control could be presented without any formatting or could be formatted using only lt BR gt and lt P gt tags. Most examples of the Repeater control, including the...

Info

Can't be overloaded, but are evaluated using the amp and operators, which can be overloaded. Can't be overloaded, but the same effect can be obtained using indexers. This operator can be used, for example, to create a virtual array. Can't be overloaded, but the same effect can be obtained using conversion operators implicit and explicit . Can't be overloaded, although they are evaluated so that, for example, uses the operator. , comma , , , - gt , new, is, sizeof, typeof There's a television...

Using Web Method Attribute Properties

The WebMethod attribute accepts six properties to control how the XML Web service operates. These properties are described in Table 10-1. Table 10-1 Properties of the WebMethod Attribute Enables buffering of responses from the XML Web service. The default value is true, and this is almost always the best setting. If set to false, the response from the XML Web service will be sent to the requesting client in 16-KB blocks. The syntax for setting this parameter is shown here Visual Basic.NET C...

Using the IEnumerator Interface

As we examine the support within the .NET Framework for various types of data handling, it's important to understand some of the details of implementation. As you'll see, using the .NET Framework, you'll be able to use a great variety of objects to access data. All of this access, whether the underlying data is in an array, in a SQL Server database, or in an XML document, will have one thing in common it will take place through the IEnumerator interface. Recall that interfaces are the...

How Aspnet Uses Client Side Scripting

One common control used on many forms is a drop-down list with several options. Based on the user's selection in the drop-down list, options in the form are customized to reflect the current selection. Selecting an item in a drop-down list doesn't cause a round-trip to the server, but client-side scripting can be used to cause a round-trip to the server. Listing 7-1 shows PostTest.aspx, an .aspx file created in Visual Studio .NET. Listing 7-1 PostTest.aspx, a page that generates a postback when...

Introduction to Aspnet Development

Although this book is about ASP.NET, you can't fully appreciate this new technology unless you understand how Web development has evolved over the last few years. In this first chapter, I'll provide you with a brief history of the various ways in which Web applications have traditionally been developed. I'll start with HTML and then go quickly through the Common Gateway Interface CGI , the Internet Server Application Programming Interface ISAPI , and Active Server Pages ASP . Although these...