R

RadioButton control, 85 exercise, 86-88 making mutually exclusive, 87 RadioButtonList control, 85, 170-173 hierarchy, 171 RaisePostbackEvent method, of server control, 56 RaisePostDataChangedEvent method, of server control, 56 for mobile applications, 746 RawUrl property, of Request object, 567 RawValue property, of PerformanceCounter object, 799 Read method, of DbDataReader object, 304 reading XML files, using XmlTextReader, 375 ReadNode method, for XMLDocument and XmlDataDocument, 350...

Programming the Web Config File Settings

You (or a systems administrator) can make many standard configuration changes using the ASP.NET Web Site Administration tool. For other changes, you need to edit the Web.config XML file. That works well when you need to manually make changes, but there are other times when you might want to programmatically edit configuration settings, such as in the following scenarios During initial configuration of the Web.config file during setup, based on user input As part of a custom application...

Info

AttachDbFilename, The full or relative path and name of a file containing extended properties, initial the database to be attached to. The path supports the file name keyword string DataDirectory , which points to the application's data directory. The database must reside on a local drive. The log file name must be in the format < database-File-Name> _log.ldf or it will not be found. If the log file is not found, a new log file is created. Initial Catalog, database The name of the database...

Note Net 20

The TreeView is new in ASP.NET version 2.0. Abstract Class i BaseDataBoundControl S AutoGenerateDataBindings Wi Collapseimage ool ip H CollapseimageUrl W EnableClientScript H ExpandDepth W Expandimage ool ip H ExpandimageUrl H HoverNodeStyle imageSet H LeafNodeStyle LevelStyles H LineimageFolder H MaxDataBindDepth Nodeindent H NodeStyle NodeWrap H NoExpandimageUrl H ParentNodeStyle PathSeparator H PopulateNodesFromClient m RootNodeStyle H SelectedNodeStyle B SelectedValue ShowCheckBoxes H...

Storing and Retrieving Binary Large Object BLOB Data

When working with data, one challenge is to move large objects between the client application and the database server. In some scenarios, you might be able to treat large-object data just like any other data, but in many cases, you might be forced to look at alternative approaches. In ADO.NET you can work with BLOBs by using a SqlDataReader object to return a result set, by using a SqlDataAdapter object to fill a DataTable object, or by using a SqlParameter configured as an output parameter. If...

Lab Using Web Parts

In this lab, you create a Web page that uses Web Parts. You then expand the page capabilities to enable users to customize the page, and then add controls that communicate with each other. Exercise 1 Create a Web Page with Web Parts In this exercise, you create a Web page that uses Web Parts and enables the user to arrange and modify the Web Parts. 1. Create a new ASP.NET Web site named MyWebParts in either C or Visual Basic using Visual Studio 2005. 2. From the Toolbox, under WebParts, drag a...

The XML Document Object Model

The W3C has provided standards that define the structure and provide a standard programming interface that can be used in a wide variety of environments and applications for XML documents. This is called the Document Object Model (DOM). Classes that support the DOM are typically capable of random access navigation and modification of the XML document. The XML classes are accessible by setting a reference to the System.Xml.dll file and adding the Imports System.Xml (C using System.Xml )...

Lab Working With Site Navigation

In this lab, you create a Web application using frames. The top frame contains a title for your Web application and a SiteMapPath control. The left frame contains a Tree-View control for navigation. Clicking any node on the TreeView or SiteMapPath controls cause the main frame to load the desired page. Exercise 1 Create the Web Application Project and Its Frames In this exercise, you create the Web application project. You also configure Default.aspx to be a frames page and add the top and left...

Navigating Data Table Objects with Data Relation Objects

The DataRelation object is used to join two DataTable objects that are in the same DataSet, thus providing a navigable path between the two DataTable objects. The DataRelation can be traversed from parent DataTable to child DataTable or from child DataTable to parent DataTable. The following code example populates the Company and Employee DataTable objects and then performs DataRelation object navigation Protected Sub Button2_Click ByVal sender As Object, _ ByVal e As System.EventArgs Handles...

Open Wave

One of the common cell phone emulator providers is OpenWave you can download the latest phone emulators from http developer.openwave.com. Figure 12-1 shows the generic phone emulator. In addition, OpenWave also provides skins for many popular phones. Figure 12-1 The OpenWave generic phone emulator. When the generic phone is displayed, the Simulator Console window is also displayed, as shown in Figure 12-2. The Simulator Console window displays the raw Hypertext Transfer Protocol HTTP and header...

Configuring Deployment Properties

Many Web applications do not require custom configuration. More complex Web applications might have complex dependencies such as particular operating system versions or service packs , require custom registry entries, or need administrator configuration. You can use Web Setup Projects to deploy Web applications to meet any of these requirements. The sections that follow discuss how to do this in more detail. Configuring Launch Conditions You can specify launch conditions to restrict the...

Adding an Master Type Declaration in a Content Page

Before you can reference master properties in a content page, you must add the MasterType declaration to the .aspx content page below the Page declaration, as the following demonstrates lt Page Language VB CodeFi1e Home.aspx.vb Inherits Home Tit1e Contoso Home Page gt lt MasterType gt lt Page Language C CodeFi1e Home.aspx.cs Inherits Home Tit1e Contoso Home Page gt lt MasterType gt You are now ready to reference master properties. However, the Visual Studio 2005 development environment might...

Using the DbData Reader Object

A DbDataReader object provides a high-performance method of retrieving data from the data store. It delivers a forward-only, read-only, server-side cursor. This makes the DbDataReader object an ideal choice for populating ListBox controls, DropDownList controls, and even GridView controls that display read-only data. When you run reports, you can use the DbDataReader object to retrieve the data from the data store. The DbDataReader might not be a good choice when you are coding an operation...

Lesson Review

You can use the following questions to test your knowledge of the information in Lesson 2, Using the ADO.NET Connected Classes. The questions are also available on the companion CD if you prefer to review them in electronic form. Answers to these questions and explanations of why each answer choice is right or wrong are located in the Answers section at the end of the book. 1. Which of the following ways can you proactively clean up a database connection's resources Choose two. A. Execute the...

Using the DbData Adapter Object

The DbDataAdapter object is used to retrieve and update data between a DataTable and a data store. The DbDataAdapter is derived from the DataAdapter class and is the base class of the provider-specific DbDataAdapter classes, as shown in Figure 4-14. Figure 4-14 The DbDataAdapter hierarchy, showing the DataAdapter base class and the provider-specific derived classes Figure 4-14 The DbDataAdapter hierarchy, showing the DataAdapter base class and the provider-specific derived classes The...

Aspnet Web Events

ASP.NET includes many different types of events that can be sent through any of the event providers. These events are listed in Table 13-6. Represents a significant event in the lifetime of an ASP.NET application. Application lifetime events include events such as application startup and shutdown events. If an application is terminated, you can determine why by viewing the related eventmessage field. Serves as the base class for all ASP.NET health-monitoring audit events. Provides information...

The Literal Control

The Literal control is similar to the Label control, as both controls are used to display static text on the Web page. The Literal control does not inherit from WebControl, as shown in the Literal control's object model in Figure 3-1. The Literal control does not provide substantial functionality and does not add any HTML elements to the Web page where the Label is rendered as a lt span gt tag. This means that the Literal does not have a Style property, and you cannot apply any styles,...

Introducing Data Bound Controls

Data-bound controls are controls that need to bind, or connect, to data. The data-bound controls are classified as simple, composite, or hierarchical controls. Simple data-bound controls are the controls that inherit from the ListControl and the AdRotator controls. Composite data-bound controls are classes that inherit from Composite-DataBoundControl, such as the GridView, DetailsView, and FormsView controls. Hierarchical data-bound controls are the Menu and TreeView controls. The .NET...

Performing Bulk Copy Operations with the Sql BulkCopy Object

The SqlBulkCopy class provides a high-performance method for copying data to a table in a SQL Server database. The source of the copy is constrained to the overloads of the WriteToServer method, which can accept an array of DataRow objects, an object that implements the IDbDataReader interface, a DataTable object, or a DataTable and DataRowState, as shown in Figure 4-13. This variety of parameters means that you can retrieve data from most locations.

Creating a Templated User Control

A templated user control provides separation of control data from its presentation, meaning that a templated user control does not provide a default user interface. For example, if you know that you need to display your shipper's information, such as the shipper ID, the shipper name, and the shipper phone number, but you don't know how the page designer wants to format this information, you could create a templated user control called ShipperControl that allows the page designer to supply the...

Dbq

Typically, the physical path to a data source. Working with Sample ODBC Connection Strings The following connection string instructs the text driver to treat the files that are located in the C Sample MySample-Folder subdirectory as tables in a database. Driver Microsoft Text Driver .txt .csv DBQ C Samp1e MySamp1eFo1der The following connection string instructs the Access driver to open the Northwind database file that is located in the C Program Files mySampleFolder folder. Driver Microsoft...

Sign Out Removes the authentication ticket essentially logging the user off Creating a Custom Forms Authentication Page

When using forms authentication, you must include two sections at a minimum A forms authentication page A method for users to log off and close their current sessions To create a forms authentication page, create an ASP.NET Web form to prompt the user for credentials and call members of the System.Web.Security.FormsAuthentication class to authenticate the user and redirect him or her to a protected page. The following code sample demonstrates an overly simple authentication mechanism that just...

Exercise 1 Create a Web Setup Project

In this exercise, you create a new ASP.NET Web site and a Web Setup Project. 1. In Visual Studio 2005, create a new Web site. 2. In Visual Studio, select the File menu, select Add, and then select New Project. 3. Under Project Types, expand Other Project Types, and then select Setup And Deployment. Under Templates, click Web Setup Project. In the Name field, type MyWebSetup. Then click OK. 4. Visual Studio adds the project to your Web site and displays the File System editor. Right-click Web...

Working with Naming Containers and Child Controls

A Web page is made up of a hierarchy of controls. The System.Web.UI.Control class, which is the class that the Web page and its controls inherit from, has a Controls collection property. This means that the Web page has a Controls collection, each of the controls in that collection has its own Controls collection, and so on. The Web page is a naming container for the controls that are added to it. A naming container defines a unique namespace for control names. Within a naming container, every...

The Image Control

The Image control is used to display an image on a Web page. This control generates an lt img gt element when rendering to HTML. The Image control inherits directly from the Web control class, and the ImageMap and ImageButton inherit from the Image control, as shown in Figure 3-5. Figure 3-5 The Image control hierarchy. Figure 3-5 The Image control hierarchy. The Image control's primary property, ImageUrl, indicates the path to the image that is downloaded from the browser and displayed. This...

Lab Store State Management Data on the Client

In this lab, you use different client-side state management techniques to track the number of pages a user opens. Exercise 1 Store Data in View State In this exercise, you add custom values to the ViewState object and then test the behavior when browsing to different pages. 1. Create a new ASP.NET Web site named ClientState in either C or Visual Basic using Visual Studio 2005. 2. In the blank project, on the Default.aspx page, add a label named Labell, a button named Buttonl, and a hyperlink...

Take a Practice Test

The practice tests on this book's companion CD offer many options. For example, you can test yourself on just the content covered in this chapter, or you can test yourself on all the 70-528 certification exam content. You can set up the test so that it closely simulates the experience of taking a certification exam, or you can set it up in study mode so that you can look at the correct answers and explanations after you answer each question. For details about all the practice test options...

Adding a Custom Web Server Control to the Toolbox

In the previous example, the control was added to the Web page dynamically by placing code in the code-behind page to instantiate and set the properties of the control. If you choose this method, you may also want to drag and drop your custom control from the Toolbox onto a Web page. This basic requirement to having your Web control in the Toolbox is that the Web control be placed into a .dll file. In the case of the previous LogoControl example, the LogoControl class has been added to a Class...

Using the DbCommand Object

The DbCommand object is used to send one or more Structured Query Language SQL statements to the data store. The DbCommand can be any of the following types Data Manipulation Language DML Commands that retrieve, insert, update, or delete data. Data Definition Language DDL Commands that create tables or other database objects, or modify the database schema. Data Control Language DCL Commands that grant, deny, or revoke permissions. The DbCommand object requires a valid open connection to issue...

Programmatically Invalidating Cached Pages

Often, you want to cache pages, but specific events might require you to stop using the cached page. For example, a page that displays results from a database query should only be cached until the results of the database query change. Similarly, a page that processes a file should be cached until the file is changed. Fortunately, ASP.NET gives you several ways to invalidate cached pages. The sections that follow describe how to make caching choices before returning a page and how to create a...

Asynchronous Web Page Programming

Asynchronous programming allows a process to have multiple threads, enabling the process to do more than one action simultaneously. While asynchronous programming can be complicated, it can dramatically improve performance in situations where the process would otherwise need to wait for a relatively slow action, such as accessing a network resource, to occur. If you have done asynchronous programming in Windows Forms applications, you can also use those techniques in ASP.NET Web forms. However,...

The Hierarchical DataBound Control Control

The HierarchicalDataBoundControl control serves as a base class for controls that render data in a hierarchical fashion. The classes that inherit from HierarchicalDataBound-Control are TreeView and Menu, as shown in Figure 3-48. Figure 3-48 The HierarchicalDataBoundControl class hierarchy. Figure 3-48 The HierarchicalDataBoundControl class hierarchy.

Cls

In the command prompt window, type the following command to start the Telnet client 4. Configure Telnet to echo type characters. Type the following command into the Telnet window, which will cause locally typed characters to be displayed while you type them Telnet will respond with the following Local echo on 5. Set carriage return and line feed to On. Type the following command to instruct Telnet that it should treat the Enter key as a combination of carriage return and line...