- •Table of Contents
- •C# and the .NET Platform, Second Edition
- •Introduction
- •Part One: Introducing C# and the .NET Platform
- •Part Two: The C# Programming Language
- •Part Three: Programming with .NET Assemblies
- •Part Four: Leveraging the .NET Libraries
- •Part Five: Web Applications and XML Web Services
- •Obtaining This Book's Source Code
- •The .NET Solution
- •What C# Brings to the Table
- •The Role of the Assembly Manifest
- •Summary
- •Chapter 2: Building C# Applications
- •Summary
- •Chapter 3: C# Language Fundamentals
- •Defining Program Constants
- •Defining Custom Class Methods
- •C# Enumerations
- •Summary
- •The Second Pillar: C#'s Inheritance Support
- •Summary
- •Catching Exceptions
- •Finalizing a Type
- •Garbage Collection Optimizations
- •Summary
- •Chapter 6: Interfaces and Collections
- •Building Comparable Objects (IComparable)
- •Summary
- •Summary
- •Internal Representation of Type Indexers
- •Summary
- •An Overview of .NET Assemblies
- •Understanding Delayed Signing
- •Using a Shared Assembly
- •GAC Internals
- •Summary
- •Spawning Secondary Threads
- •A More Elaborate Threading Example
- •Summary
- •Summary
- •Object Persistence in the .NET Framework
- •The .NET Remoting Namespaces
- •Understanding the .NET Remoting Framework
- •All Together Now!
- •Terms of the .NET Remoting Trade
- •Testing the Remoting Application
- •Revisiting the Activation Mode of WKO Types
- •Deploying the Server to a Remote Machine
- •Summary
- •Control Events
- •The Form Class
- •Summary
- •Regarding the Disposal of System.Drawing Types
- •Understanding the Graphics Class
- •Summary
- •The TextBox Control
- •Working with Panel Controls
- •Configuring a Control's Anchoring Behavior
- •Summary
- •Chapter 16: The System.IO Namespace
- •The Static Members of the Directory Class
- •The Abstract Stream Class
- •Summary
- •The Role of ADO.NET Data Providers
- •The Types of System.Data
- •Selecting a Data Provider
- •The Types of the System.Data.OleDb Namespace
- •Working with the OleDbDataReader
- •Summary
- •Submitting the Form Data (GET and POST)
- •Some Benefits of ASP.NET
- •Creating an ASP.NET Web Application by Hand
- •The Composition of an ASP.NET Page
- •The Derivation of an ASP.NET Page
The Composition of an ASP.NET Page |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Recall that the <%@Page%> directive is used to specify the name of the code behind file, as well as the
Apress © 2003 (1200 pages)
name of the class in said file that becomes your base class:
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
<%@ Page language="c#" Codebehind="BetterAspNetCarApp.aspx.cs" AutoEventWireup="false"Inherits="BetterAspNetCarApp.WebForm1" %>
Table of Contents
C# and the .NET Platform, Second Edition
As you can see, the value of the Inherits attribute is the fully qualified name of the System.Web.UI.Page-
Introduction
derived type (which by default will be named WebForm1). Because the Inherits attribute works in PartconjunctionOne - I troducingwith the fileC#specifiedand the .NETby thePlatformCodebehind attribute, be aware that if you wish to change the Chnamept rof1 the- TheclassPhinlosophyyour codef .NETbehind as follows:
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
public class CarInventoryPage : System.Web.UI.Page
Chapter 3 - C# Language Fundamentals
{ ... }
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
you will need to update the value of the related *.aspx file's Inherits attribute identically:
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter<%@ Page8 - Advancedlanguage="c#"C# Type ConstructionCodebehind="BetterAspNetCarAppTechniques .aspx.cs"
PartAutoEventWireup="false"Three - Prog amming with .NETInherits="BetterAspNetCarAppAssemblies .CarInventoryPage" %>
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
When you first begin to work with code behind, one slightly odd concept to wrap your head around is that
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
when you are writing code in the *.aspx file, you can reference the custom methods and properties defined
Part Four - Leveraging the .NET Libraries
in the designated code behind file. Assume you have built a simple function that obtains the current time
Chapter 12 - Object Serialization and the .NET Remoting Layer and date:
Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
public class SomeWebForm: System.Web.UI.Page
Chapter 15 - Programming with Windows Forms Controls
{
Chapter 16 - The System.IO Namespace
...
Chapter 17 - Data Access with ADO.NET public string GetDateTime()
Part Five - Web Applications and XML Web Services
{return DateTime.Now.ToString(); }
Chapter 18 - ASP.NET Web Pages and Web Controls
}
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
IndexTo reference this method in your *.aspx code, you can write the following:
List of Figures
List of Tables
<body>
<!-- Get the time from the C# class -->
<% Response.Write(GetDateTime()); %>
...
<form method="post" runat="server" ID=Form1> </form>
</body>
Here, the C# code block is not only triggering the GetDateTime() method in the code behind file, but also making use of the inherited Response property defined by the System.Web.UI.Page base class. To build a more compact *.aspx file, you could make reference to the inherited Page members directly in your code behind class. Thus, you could also write the following:
public class SomeWebForm : System.Web.UI.Page
{
...
}
C# and the .NET Platform, Second Edition public void GetDateTime()
{ |
by Andrew Troelsen |
ISBN:1590590554 |
|
|
Apress © 2003 (1200 pages)
Response.Write("It is now " + DateTime.Now.ToString());
}This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
And then simply call:
Table of Contents
C# and the .NET Platform, Second Edition
<!-- Get the time -->
Introduction
<% GetDateTime(); %>
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Again, if you wish to follow the standard philosophy of ASP.NET, you will attempt to avoid making use of
Part Two - The C# Programming Language
server-side code logic within your *.aspx files. However, in the event that you do wish to trigger a method in
Chapter 3 - C# Language Fundamentals
your code behind file, do attempt to build methods that can be invoked as cleanly as possible (as seen Chere)apter. In4 this- Objectway, -allOrientedof yourProgramming"real" code iswithsafeC#within your *.aspx.cs file while the GUI widgets defined in
Chapterthe *.aspx5 -fileExcaneptionsbe scrappedand ObjectasLifneededtime .
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The DerivationC# andofthean.NETASPPlatform,.NETSecondPageEdition
by Andrew Troelsen |
ISBN:1590590554 |
Each *.aspx file is ultimately represented by a class deriving from System.Web.UI.Page. Like any base
Apress © 2003 (1200 pages)
class, this type provides a polymorphic interface to all derived types. However, the Page type is not the
This comprehensive text starts with a brief overview of the
only member in yourC# languageinheritanceandhierarchythen quickly. Figuremoves18-to17keydocumentstechnical andthe full chain of inheritance for a custom page. architectural issues for .NET developers.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Figure 18-17: The derivation of an ASP.NET page
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Key Members of the System.Web.UI.Page Type
Chapter 7 - Callback Interfaces, Delega es, and Events
Chapter 8 - Advanced C# Type Construction Techniques
The first parent class of interest is Page itself. Here you will find numerous properties that mimic the
Part Three - Programming with .NET Assemblies
classic COM objects of classic ASP. Table 18-6 describes some (but by no means all) of the core
Chapter 9 - Understanding .NET Assemblies properties.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Table 18-6: Properties of the Page Type
Part Four - Leveraging the .NET Libraries
ChapterSystem12 .-WebObject.UISeri.Pagelization andMeaningthe .NET Remotin Lifeng Layer |
||||||
ChapterProperty13 - Building a Better Window (Introducing Windows Forms) |
||||||
|
|
|
|
|
|
|
|
Chapter 14 - A Better Painting Framework (GDI+) |
|
||||
|
Application |
|
|
Gets the HttpApplicationState object provided by the runtime |
|
|
|
Chapter 15 - Programming with |
|
Windows Forms Controls |
|
||
|
|
|
|
|||
|
ChapterCache16 |
- The System.IO NamespaceIndicates the Cache object in which to store data for the page's |
|
|||
|
Chapter 17 |
- Data Access with ADO.applicationNET |
|
|||
|
|
|
|
|
||
Part Five - Web Applications and |
|
XML Web Services |
|
|||
|
IsPostBack |
|
|
Gets a value indicating whether the page is being loaded in |
|
|
Chapter 18 |
- ASP.NET Web Pages |
|
and Web Controls |
|
||
Chapter 19 |
|
|
|
response to a client postback, or if it is being loaded and |
|
|
- ASP.NET Web Applications |
|
|||||
|
|
|
|
|
accessed for the first time |
|
Chapter 20 - XML Web Services
Request
Index
List of Figures
List of Tables
Response
Server
Session
Trace
Gets the HttpRequest object that provides access data from incoming HTTP requests
Gets the HttpResponse object that allows you to send HTTP response data back to a client browser
Gets the HttpServerUtility object supplied by the HTTP runtime
Gets the System.Web.SessionState.HttpSessionState object, which provides information about the current request's session
Provides access to the System.Web.TraceContext type, which allows you to log custom messages during debugging sessions
InteractingC#withand thee .NETIncomingPlatform, SecondHTTPEditionRequest
by Andrew Troelsen |
ISBN:1590590554 |
As you have seen earlier in this chapter, the basic flow of a Web session begins with a client logging onto a
Apress © 2003 (1200 pages)
site, filling in user information, and clicking a Submit button to post back the HTML form data to a given Web
This comprehensive text starts with a brief overview of the
page for processingC#.languageIn most cases,and thenthequicklyopeningmovestag ofto thekeyformtechnicalstatementand specifies an action and method attribute that indicatesarchitecturalthe fileissueson theforWeb.NETserverdevelopersthat will. be sent the data in the various HTML widgets, and the method of sending this data (GET or POST). Here is an example:
Table of Contents
<form name=MainForm action="http://localhost/default.aspx"method=get ID=Form1>
C# and the .NET Platform, Second Edition
Introduction
PartUnlikeOneclassic- IntroducingASP, ASPC# .andNETthedoes.NETnotPlatformsupport an object named Request. However, all ASP.NET pages do Chapterinherit the1 -SystemThe Philosophy.Web.UI.Pageof .NET.Request property, which provides access to the raw HTTP request. Under
Chapterthe hood,2 this- BuildingpropertyC#manipulatesApplications an instance of the HttpRequest class type. Table 18-7 lists some core
PartmembersTwo - Tthat,e C#notProgsurprisingly,amming Languagemimic the same members found within the classic COM Request object.
Chapter 3 - C# Language Fundamentals
ChTablept r 184 -7:- ObjectMembers-O ientedof theProgrammingHttpRequestwithTypeC#
Chapter 5 - Exceptions and Object Lifetime
System.Web.HttpRequest |
Meaning in Life |
Chapter 6 - Interfaces and Collections |
|
Member |
|
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterApplicationPath8 - Advanced C# Type Construction GetsT chniquesthe virtual path to the currently executing server
Part Three - Programming with .NET Assembliesapplication.
|
Chapter 9 - Understanding .NET Assemblies |
|
|
|
Provides information about incoming client's browser |
|
|
Browser |
|
|
|
|
|
|
Chapter 10 - Processes, AppDomains, Contexts, and Threads |
|
||||
|
|
|
|
|
capabilities. |
|
|
Chapter 11 - Type Reflection, Late Binding, |
and Attribute-Based Programming |
|
|||
|
|
|||||
PartCookiesF ur - Leveraging the .NET Libraries |
|
|
Gets a collection of client's cookie variables. |
|
||
|
|
|
|
|
||
|
Chapter 12 - Object Serialization and the .NET |
|
Remoting Layer |
|
||
|
FilePath |
|
Indicates the virtual path of the current request. This |
|
||
|
Chapter 13 - Building a Better Window (Introducing Windows Forms) |
|
||||
|
|
|
|
|
property is read-only. |
|
|
Chapter 14 - A Better Painting Framework (GDI+) |
|
||||
|
|
|||||
|
ChapterFiles 15 - Programming with Windows FormsGetsControlsthe collection of client-uploaded files (multipart MIME |
|
||||
|
Chapter 16 - The System.IO Namespace |
|
|
format). |
|
|
|
|
|
|
|||
|
Chapter 17 - Data Access with ADO.NET |
|
|
|
Gets or sets a filter to use when reading the current input |
|
|
Filter |
|
|
|
|
|
Part Five - Web Applications and XML Web |
|
|
|
Services |
|
|
|
|
|
|
|
stream. |
|
|
Chapter 18 - ASP.NET Web Pages and Web |
|
|
|
Controls |
|
|
|
|
|
|
||
|
Form |
|
|
|
Gets a collection of Form variables. |
|
|
Chapter 19 - ASP.NET Web Applications |
|
|
|
|
|
|
|
|
|
|
||
|
Chapter 20 - XML Web Services |
|
|
|
Gets a collection of HTTP headers. |
|
|
Headers |
|
|
|
|
|
|
|
|
|
|
|
|
Index |
|
|
|
Indicates the HTTP data transfer method used by the |
|
|
|
HttpMethod |
|
|
|
|
|
List of Figures |
|
|
|
client (GET, POST). |
|
|
List of Tables |
|
|
|
|
||
|
|
|
|
|
||
|
IsSecureConnection |
|
|
|
Indicates whether the HTTP connection is secure (that is, |
|
|
|
|
|
|
HTTPS). |
|
|
|
|
|
|
||
|
QueryString |
|
|
|
Gets the collection of QueryString variables. |
|
|
|
|
|
|
||
|
RawUrl |
|
|
|
Gets the current request's raw URL. |
|
|
|
|
|
|
||
|
RequestType |
|
|
|
Indicates the HTTP data transfer method used by the |
|
|
|
|
|
|
client (GET, POST). |
|
|
|
|
|
|
||
|
ServerVariables |
|
|
|
Gets a collection of Web server variables. |
|
|
|
|
|
|
||
|
UserHostAddress |
|
|
|
Gets the IP host address of the remote client. |
|
|
|
|
|
|
||
|
UserHostName |
|
|
|
Gets the DNS name of the remote client. |
|
Again, for those of you who have experience with classic ASP, it is important to point out that there is no
object named Request (or Response). Thus, when you author a block of ASP.NET code such as the
C# and the .NET Platform, Second Edition
following:
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
<b>You Are: </b><%= Request.ServerVariables["HTTP_USER_AGENT"] %>
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
what you are really doing is accessing the ServerVariables property on the underlying HttpRequest type, as shown here:
Table of Contents
C#<b>Youand theAre:.NET Platform,</b> Second Edition
<%
Introduction
HttpRequest r;
Part One - Introducing C# and the .NET Platform
r = this.Request;
Chapter 1 - The Philosophy of .NET
Response.Write(r.ServerVariables["HTTP_USER_AGENT"]);
Chapter 2 - Building C# Applications
%>
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
ChapterObtaining5 - ExceptionsBrowserand ObjectStatisticsLifetime
Chapter 6 - Interfaces and Collections
The first interesting aspect of HttpRequest is the Browser property, which provides access to an underlying
Chapter 7 - Callback Interfaces, Delegates, and Events
HttpBrowserCapabilities object. HttpBrowserCapabilities in turn exposes a set of members that allow you to
Chapter 8 - Advanced C# Type Construction Techniques
programmatically investigate various statistics regarding the browser that sent the incoming HTTP request.
Part Three - Programming with .NET Assemblies
To illustrate, assume you have a new ASP.NET Web application that contains a single *.aspx file. When the
Chapter 9 - Understanding .NET Assemblies
user clicks the Button Web control, the server-side event handler will create a System.String that contains
Chapter 10 - Processes, AppDomains, Contexts, and Threads
various statistics about the client-side browser and display the results on a Label Web control. The Button
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Click event handler is as follows:
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
private void btnGetBrowserStats_Click(object sender, System.EventArgs e)
Chapter 13 - Building a Better Window (Introducing Windows Forms)
{
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET theInfo +=
Part Five - Web Applications and XML Web Services
String.Format("<li>Does the client support ActiveX? {0}",
Chapter 18 - ASP.NET Web Pages and Web Controls
Request.Browser.ActiveXControls);
Chapter 19 - ASP.NET Web Applications |
|
theInfo += String.Format("<li>Is the client a Beta? {0}", |
|
Chapter 20 - XML Web Services |
|
|
Request.Browser.Beta); |
Index theInfo += |
|
List of Figures |
String.Format("<li>Dose the client support Applets? {0}", |
List of Tables |
Request.Browser.JavaApplets); |
theInfo +=
String.Format("<li>Does the client support Cookies? {0}",
Request.Browser.Cookies);
theInfo +=
String.Format("<li>Does the client support VBScript? {0}",
Request.Browser.VBScript);
lblOutput.Text = theInfo;
}
Here you are testing for a number of browser capabilities. As you would guess, it is (very) helpful to discover a browser's support for ActiveX controls, Java Applets, and client-side VB Script code. If the calling browser does not support a given Web technology, your *.aspx page would be able to take an alternative course of action.
Simplified Access to Server Variables
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Another aspect of HttpRequest is a simplified manner to obtain server variables. In classic ASP, you
Apress © 2003 (1200 pages)
accessed server variables using a parameterized property of the Request object. Using this collection
This comprehensive text starts with a brief overview of the required you to memorize numerous string literals such as this one:
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
string agent = Request.ServerVariables["HTTP_USER_AGENT"];
Table of Contents
While you are still able to access server variables using this classic ASP-like mindset, ASP.NET provides
C# and the .NET Platform, Second Edition
strongly typed properties of the HttpRequest type for an identical purpose. To illustrate, update your current
Introduction
*.aspx file to include a new Button type. In the Click event handler, scrape out various server-side
Part One - Introducing C# and the .NET Platform
characteristics. For example:
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
PartprivateTwo - ThevoidC# ProgrammingbtnGetRequestStatsLanguage _Click(object sender, System.EventArgs e)
{
Chapter 3 - C# Language Fundamentals
string theInfo = "";
Chapter 4 - Object-Oriented Programming with C#
theInfo += String.Format("<li>Path of Virtual directory? {0}",
Chapter 5 - Exceptions and Object Lifetime
Request.ApplicationPath);
Chapter 6 - Interfaces and Collections
theInfo += String.Format("<li>Byte length of request? {0}",
Chapter 7 - Callback Interfaces, Delegates, and Events
Request.ContentLength);
Chapter 8 - Advanced C# Type Construction Techniques
theInfo += String.Format("<li>Virtual path? {0}",
Part Three - Programming with .NET Assemblies
Request.FilePath);
Chapter 9 - Understanding .NET Assemblies
theInfo += String.Format("<li>Http method? {0}",
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Request.HttpMethod);
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming theInfo += String.Format("<li>Raw URL? {0}",
Part Four - Leveraging the .NET Libraries
Request.RawUrl);
Chapter 12 - Object Serialization and the .NET Remoting Layer
theInfo += String.Format("<li>IP address? {0}",
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Request.UserHostAddress);
Chapter 14 - A Better Painting Framework (GDI+)
theInfo += String.Format("<li>DNS name? {0}",
Chapter 15 - Programming with Windows Forms Controls
Request.UserHostName);
Chapter lblOutput16 - The System.Text.IO Namespace= theInfo;
Chapter //17 -NowDatasaveAccessallwith ADOstats.NETto file.
Part FiveRequest- Web Applications.SaveAs(@"C:\temp\requestDumpand XML Web Servic .txt", true);
Chapter} 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Notice that the final line of this server-side event handler makes a call to HttpRequest.SaveAs(). This method
Index
allows you to dump out all the characteristics regarding the current HTTP request to a physical file on the
Web server (which may optionally include header information, specified via the second System.Boolean
List of Tables
parameter). As you would guess, this functionality can be quite helpful during debugging.
Note Be aware that if your Web application makes use of any file IO logic (such as the HttpRequest.SaveAs() method), the target file must be configured for writing.
Access to Incoming Form Data
The final aspect of the HttpResponse type we will examine here is the use of the Form and QueryString properties. These two properties allow you to examine the incoming form data using name/value pairs, and function identically to classic ASP. Recall from our discussion of classic ASP at the onset of this chapter that if the data is submitted using HTTP GET, the form data is accessed using the QueryString property, whereas data submitted via HTTP POST is obtained using the Form property.
While you could most certainly make use of the HttpRequest.Form and HttpRequest.QueryString properties to access client-supplied form data on the Web server, these old school techniques are (for the most part) unnecessary. Given that ASP.NET now supplies you with server-side Web controls, you are able to treat
HTML form widgets as true objects. Therefore, rather than obtaining the value within a text box as follows:
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
string firstName = Request.Form["txtFirstName"];
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and you can simply ask the server-side widget directly:
architectural issues for .NET developers.
string firstName = txtFirstName.Text;
Table of Contents
C# and the .NET Platform, Second Edition
Not only does this approach lend itself to solid OO principals, but you do not need to concern yourself with
Introduction
how the form data was submitted (GET or POST) before obtaining the values. Of course, this is not to say
Part One - Introducing C# and the .NET Platform
that you will never need to make use of the Form or QueryString properties in ASP.NET, but rather to say
Chapter 1 - The Philosophy of .NET
that the need to do so has greatly diminished.
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
SOURCE The FunWithHttpRequest files are included under the Chapter 18 subdirectory.
Chapter 3 - C# Language Fundamentals
CODE
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
InteractingC#withand thee .NETOutgoingPlatform, SecondHTTPEditionResponse
by Andrew Troelsen |
ISBN:1590590554 |
Now that you have a better understanding how a System.Web.UI.Page-derived type can interact with the
Apress © 2003 (1200 pages)
incoming HTTP request, the next step is to see how to interact with the outgoing HTTP response. In
This comprehensive text starts with a brief overview of the
ASP.NET, the ResponseC# languagepropertyand thenof thequicklyPagemovesclass providesto key technicalaccessandto an internal HttpResponse type. This type definesarchitecturala number ofissuespropertiesfor .NETthatdevelopersallow you.to format the HTTP response sent back to the client browser. Table 18-8 lists some core properties (many of which should look familiar if you have a classic ASP background).
Table of Contents
C# and the .NET Platform, Second Edition |
|
|
|
|
|||
|
Table 18-8: Properties of the HttpResponse Type |
||||||
|
|
Introduction |
|
|
|
|
|
PartSystem.Web.HttpResponseOne - Introducing C# and the .NET PlatformMeaning in Life |
|
|
|||||
|
ChapterProperty1 - The Philosophy of .NET |
|
|
|
|
||
|
|
|
|
|
|
||
|
|
Chapter 2 |
- Building C# Applications |
|
Returns the caching semantics of the Web page (e.g., |
|
|
|
|
Cache |
|
|
|
|
|
Part Two - The C# Programming Language |
|
expiration time, privacy, vary clauses) |
|
|
|||
|
|
|
|
|
|
|
|
|
Chapter 3 |
- C# Language Fundamentals |
|
|
|
|
|
|
|
|
Gets or sets the HTTP character set of the output |
|
|
||
|
|
ContentEncoding |
|
|
|
||
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
|
|||
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
stream |
|
|
|
|
|
|
|
|
|||
|
|
Chapter 6 |
- Interfaces and Collections |
|
Gets or sets the HTTP MIME type of the output stream |
|
|
|
|
ContentType |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, |
and Events |
|
|
|
|
|
Cookies |
- Advanced C# Type Construction |
|
Gets the HttpCookie collection sent by the current |
|
|
|
Chapter 8 |
Techniques |
|
|
|||
Part Three - Programming with .NET Assemblies |
request |
|
|
||||
|
|
|
|||||
|
|
Chapter 9 |
- U derstanding .NET Assemblies |
|
Gets a value indicating whether the client is still |
|
|
|
|
IsClientConnected |
|
|
|
||
|
|
Chapter 10 |
- Processes, AppDomains, Contexts, |
|
connected to the server |
|
|
|
|
a Threads |
|
|
|||
|
|
|
|
|
|
||
|
|
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
|
|
||
|
|
Output |
|
|
Enables custom output to the outgoing HTTP content |
|
|
Part Four - Leveraging the .NET Libraries |
|
body |
|
|
|||
|
|
|
|
|
|
|
|
|
Chapter 12 |
- Object Serialization and the .NET |
|
Remoting Layer |
|
|
|
|
|
|
|
|
|||
|
ChapterOutputStream13 - Building a Better Window (IntroduciEnablesg WindowsbinaryFoutputrms) to the outgoing HTTP content |
|
|
||||
|
Chapter 14 |
- A Better Painting Framework (GDI+)body |
|
|
|||
|
|
|
|
|
|
||
|
|
Chapter 15 |
- Programming with Windows Forms Controls |
|
|
||
|
|
StatusCode |
|
Gets or sets the HTTP status code of output returned |
|
|
|
|
Chapter 16 |
- The System.IO Namespace |
|
to the client |
|
|
|
|
|
Chapter 17 |
- Data Access with ADO.NET |
|
|
|
|
|
|
|
|
|
|
||
PartStatusDescriptionFive - Web Applications and XML Web |
ServicesGets or sets the HTTP status string of output returned |
|
|
||||
|
Chapter 18 |
- ASP.NET Web Pages and Web |
Controlsto the client |
|
|
||
|
|
|
|
|
|
|
|
|
|
Chapter 19 |
- ASP.NET Web Applications |
|
Gets or sets a value indicating that HTTP content will |
|
|
|
|
SuppressContent |
|
|
|
||
|
Chapter 20 |
- XML Web Services |
|
not be sent to the client |
|
|
|
|
Index |
|
|
|
|
|
List of Figures
Also, consider the methods of the HttpResponse type described in Table 18-9.
List of Tables
Table 18-9: Methods of the HttpResponse Type
|
|
|
|
|
System.Web.HttpResponseC# and the .NET Platform,MeaningSecondinEditionLife |
|
|||
Method |
by Andrew Troelsen |
|
ISBN:1590590554 |
|
|
|
|
|
|
|
Apress © 2003 (1200 pages) |
|
Adds custom log information to the IIS log file. |
|
AppendToLog() |
|
|
||
|
This comprehensive text |
|
starts with a brief overview of the |
|
|
|
|
||
Clear() |
C# language and then |
|
quickly moves to k y technical and |
|
architectural issues for |
|
Clears all headers and content output from the buffer |
|
|
|
|
.NET developers. |
|
|
|
|
|
stream. |
|
Close()
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
End()
Chapter 1 - The Philosophy of .NET
ChapterFlush()2 - Building C# Applications
Closes the socket connection to a client. This method can be helpful when you wish to terminate further control rendering.
Sends all currently buffered output to the client, then closes the socket connection.
Sends all currently buffered output to the client.
|
|
|
|
|
|
|
|
Part Two - The C# Programming Language |
|
Redirects a client to a new URL. |
|
|
|||
|
|
Redirect() |
|
|
|||
|
Chapter 3 |
- C# Language Fundamentals |
|
|
|
|
|
|
|
|
|
|
|
||
|
ChapterWrite()4 |
- Object-Oriented Programming |
|
Writeswith C#values to an HTTP output content stream. |
|
||
|
|
||||||
|
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
Overloaded. Writes a file directly to an HTTP content |
|
|
|
|
WriteFile() |
|
|
|||
|
Chapter 6 |
- Interfaces and Collections |
|
output stream. |
|
|
|
|
|
|
|
|
|
||
|
|
Chapter 7 |
- Callback Interfaces, Delegates, |
|
and Events |
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
||||||
Part Three - Programming with .NET Assemblies |
|||||||
ChapterEmitting9 - UnderstandingHTML Content.NET Assemblies |
|||||||
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
||||||
|
Perhaps the most well-known aspect of the HttpResponse type is the ability to write content directly to the |
||||||
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
HTTP output stream. The HttpResponse.Write() method behaves identically to the classic ASP
Part Four - Leveraging the .NET Libraries
Response.Write() method (simply pass in any HTML tags and/or raw text literals). The
Chapter 12 - Object Serialization and the .NET Remoting Layer
HttpResponse.WriteFile() method takes this functionality one step further in that you can specify the name
Chapter 13 - Building a Better Window (Introducing Windows Forms)
of a physical file on the Web server whose contents should be rendered to the output stream (quite helpful
Chapter 14 - A Better Painting Fr mework (GDI+) |
|
to quickly emit the contents of an existing *.html file): |
|
Chapter 15 |
- Programming with Windows Forms Controls |
Chapter 16 |
- The System.IO Namespace |
private void SomePageLevelHelperFunction() |
|
Chapter 17 |
- Data Access with ADO.NET |
{ |
|
Part Five - Web Applications and XML Web Services
Response.Write("<b>My name is:</b><br>");
Chapter 18 - ASP.NET Web Pages and Web Controls
Response.Write(this.ToString());
Chapter 19 - ASP.NET Web Applications
Response.Write("<br><br><b>Here was your last request:</b><br>");
Chapter 20Response- XML W .bWriteFileServices (@"C:\temp\requestDump.txt");
Index}
List of Figures
List of Tables
The role of this helper function (which you can assume is called by some server-side event handler) is quite simple. The only point of interest is the fact that the HttpResponse.WriteFile() method is now emitting the contents of the *.txt file created previously using the HttpRequest.SaveAs() method (to be safe, of course, you would want to wrap this method invocation within a try/catch statement just in case the requestDump.txt file is missing).
Again, while you can always take this "old school" approach and render HTML tags and content using the Write() method, this approach is far less common under ASP.NET than with classic ASP. The reason is (once again) due to the advent of server-side Web controls. For example, if you wish to render a block of textual data to the browser, your task is as simple as assigning a given System.String to the Text property of a Label widget.
Redirecting Users
Another aspect of the HttpResponse type is the ability to redirect the user to a new URL:
private void C#PassTheBuck()and the .NET Platform, Second Edition |
|
|
{ |
by Andrew Troelsen |
ISBN:1590590554 |
Response.Redirect("http://Intertech-Inc.com");
Apress © 2003 (1200 pages)
}
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
If this helper function were called via a server-side event handler, the user would automatically be redirected to the specified URL.
Table of Contents
Note The HttpResponse.Redirect() method will always entail a trip back to the client browser. If you
C# and the .NET Platform, Second Edition
simply wish to transfer control to a *.aspx file in the same virtual directory, the IntroductionHttpServerUtility.Transfer() method (accessed via the inherited Server property) will be more
Part One - Introducing C# and the .NET Platform
efficient.
Chapter 1 - The Philosophy of .NET
ChapterSo much2 for- Buildiinvestigationour C# Applicationsregarding how a given *.aspx file may interact with the incoming HTTP
PartrequestTwo -andTheoutgoingC# Pro rammingHTTP responseLanguage. I'll assume you will check out the remaining members of the ChapterHttpRequest3 - C#andLanguageHttpResponseFundamentalstypes at your leisure.
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The Life CycleC# andofthean.NETASPPlatform,.NETSecondWebEditionPage
by Andrew Troelsen |
ISBN:1590590554 |
Like a Windows Forms application, every ASP.NET Web page has a fixed life cycle. When the ASP.NET
Apress © 2003 (1200 pages)
runtime receives an incoming request for a given *.aspx file, the associated System.Web.UI.Page derived
This comprehensive text starts with a brief overview of the
type is allocated intoC# languagememoryandusingthenthequicklytype's movesdefaulttoconstructorkey te hnical. Afterandthis point, the framework will automatically firearchitethree coreturalevents:issues forInit,.NETLoad,evelopersand Unload. . By default, a VS .NET-generated code behind page will be prewired to handle the Init event (via the overloaded OnInit() method) as well as the Load event (via the standard C# event syntax and the System.EventHandler delegate):
Table of Contents
C# and the .NET Platform, Second Edition
public class MainPage: System.Web.UI.Page
Introduction
{
Part One - Introducing C# and the .NET Platform
private void Page_Load(object sender, System.EventArgs e)
Chapter 1 - The Philosophy of .NET
{ }
Chapter 2 - Building C# Applications
// Override the base class event handler.
Part Two - The C# Programming Language
override protected void OnInit(EventArgs e)
Chapter 3 - C# Language Fundamentals
{
Chapter 4 - Object-Oriented Programming with C#
InitializeComponent();
Chapter 5 - Exceptionsbase.OnInit(e);and Obj ct Lifetime
Chapter }6 - Interfaces and Collections
Chapter private7 - CallbackvoidInterfaces,InitializeComponent()De egates, and Events
{
Chapter 8 - Advanced C# Type Construction Techniques
// Rig-up the Load event!
Part Three - Programming with .NET Assemblies
this.Load += new System.EventHandler(this.Page_Load);
Chapter 9 - Understanding .NET Assemblies
}
Chapter 10 - Processes, AppDomains, Contexts, and Threads
}
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Once the Load event has been handled, the next major event to fire is whatever page-specific event
Chapter 13 - Building a Better Window (Introducing Windows Forms)
handler caused the postback to occur in the first place (such as a Button Click or what have you). Once
Chapter 14 - A Better Painting Framework (GDI+)
your page-specific event handling has completed, the framework will fire the Unload event, which is not
Chapter 15 - Programming with Windows Forms Controls
handled automatically. To do so, you may use the VS .NET Properties window (simply select the name of
Chapter 16 - The System.IO Namespace
your Web Form from the drop-down list with the designer active) or update InitializeComponent()
Chaptermanually17. - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Note The Init, Load, and Unload events are common to all ASP.NET Web controls, given that they are
Chapter 18 - ASP.NET Web Pages and Web Controls
defined in the System.Web.UI.Control base class.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Now, although you are aware of
Index
wondering what type of code will
the set of key events that fire during a page's lifetime, you are most likely end up in each handler. Table 18-10 offers some insights.
List of Figures
List of Tables
Table 18-10: The Role of the Init, Load, and Unload Events
|
Page |
|
|
MeaningC# andintheLife.NET Platform, Second Edition |
|
|
Event |
|
|
by Andrew Troelsen |
ISBN:1590590554 |
|
|
|
|
|
|
|
Init |
|
|
Apress © 2003 (1200 pages) |
|
|
|
|
The base class' implementation of the OnInit() method is in charge of handling the |
||
|
|
|
|
This comprehensive text starts with a brief overview of the |
|
|
|
|
|
view state for your ASP.NET Web controls (defined later in this chapter). Given this |
|
|
|
|
|
C# language and then quickly moves to key technical and |
|
|
|
|
|
fact,architecturalbe very awareissuesthatforwithin.NETthedevelopers.scope of the overridden Init event handler you |
|
|
|
|
|
should not add any code that directly interacts with the stateful values of a control |
|
|
|
|
|
(e.g., the value within a TextBox) as you cannot guarantee an accurate read. Typically, |
|
Table of Contentsthis event is of greatest use to WebForm control builders. You can, however, assign |
|||||
C# and the .NETvaluesPlatform,to anySecnonnd-GUIEdition-centric variables within the scope of OnInit() as well as |
|||||
|
Introduction |
|
establish the event handlers for your page's widgets. |
||
|
|
|
|
|
|
Part One - |
|
Introducing C# and the .NET Platform |
|
||
|
Load |
|
|
Once the Load event fires, you can safely interact with any Web-widgets on your page. |
|
Chapter 1 |
- |
|
The Philosophy of .NET |
|
|
|
|
|
|
Common tasks include connecting to a database to fill a DataGrid, populating a |
|
Chapter 2 |
- |
|
Building C# Applications |
|
|
|
|
|
|
ListBox with entries, and other GUI prep work. |
|
Part Two - The C# Programming Language |
|
||||
|
Unload |
|
|
When this event fires, your System.Web.UI.Page-derived type is on its way to the |
|
Chapter 3 |
- C# Language Fundamentals |
|
|||
Chapter 4 |
|
|
garbage collector. Here you should close any page-wide data connections, file |
||
- Object-Oriented Programming with C# |
|
||||
|
|
|
|
handles, and other resources. |
|
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
ChaptTher Error8 - AdvancedEventC# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Another event that may occur during your page's life cycle is Error, which also works in conjunction with
Chapter 9 - Understanding .NET Assemblies
the System.EventHandler delegate. This event will be fired if a method on the Page-derived type triggered
Chapter 10 - Processes, AppDomains, Contexts, and Threads
an exception that was not explicitly handled. Assume you have a server-side event handler for a Button Click event that attempts to open a file that is nonexistent. Also assume that you failed to test this file manipulation using standard structured exception handling. If you have rigged up the page's Error event,
you have one final chance to deal with the problem. Ponder the following code:
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
public class MainPage : System.Web.UI.Page
Chapter 15 - Programming with Windows Forms Controls
{
Chapter 16 - The System.IO Namespace
protected System.Web.UI.WebControls.Button btnTriggerError;
Chapter 17 - Data Access with ADO.NET
...
Part Five - Web Applications and XML Web Services
private void InitializeComponent()
Chapter 18 - ASP.NET Web Pages and Web Controls |
|
{ |
|
Chapter 19 - ASP.NET Web Applications |
|
|
this.btnTriggerError.Click += |
Chapter 20 - XML Web Services |
|
|
new System.EventHandler(this.btnTriggerError_Click); |
Index |
this.Error += new System.EventHandler(this.MainPage_Error); |
|
|
List of Figures |
this.Load += new System.EventHandler(this.Page_Load); |
List of Tables |
|
} |
|
private void btnTriggerError_Click(object sender, System.EventArgs e)
{
// Ack! Unhandled exception here (assume bad path)!
Response.WriteFile(@"C:\Foo.bar");
}
private void MainPage_Error(object sender, System.EventArgs e)
{
// Obtain the error and report to user.
Exception ex = Server.GetLastError();
Response.Write(ex.Message);
Server.ClearError();
}
}
C# and the .NET Platform, Second Edition
When the Error event is fired, you are able to obtain the underlying System.Exception using the HttpServerUtility.GetLastError() method exposed from the inherited Server property. In this case, I am
simply spitting back the error's description to the response stream. Do note, however, that before exiting
This comprehensive text starts with a brief overview of the
this generic error handler, I am explicitly calling HttpServerUtility.ClearError(). This is almost always what
you will want to do, as it informs the runtime that you have dealt with the issue at hand and require no architectural issues for .NET developers.
further processing. To see the distinction, Figure 18-18 shows the output if you do call HttpServerUtility.ClearError(), while Figure 18-19 shows the result of not calling
HttpServerUtility.ClearError().
Table of Contents
C# and the .NET Platform, Second Edition
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter 9 - Understanding .NET Assemblies
Figure 18-18: The result of calling ClearError()
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part |
|
Chapter |
Remoting Layer |
Chapter |
Windows Forms) |
Chapter |
|
Chapter |
Controls |
Chapter |
|
Chapter |
|
Part |
Services |
Chapter |
Controls |
Chapter |
|
Chapter |
|
Index |
|
List ofFigureFigur s18-19: The result of not calling ClearError()
List of Tables
Understanding the Role of the IsPostBack Property
Closely related to the set of page-level events is a specific inherited property named IsPostBack. As defined at the beginning of this chapter, a postback is the term given to the act of return to a particular Web page while still in session with the server. Given this definition, you are most likely already to determine that the IsPostBack property will return true if the current HTTP request has been sent by a currently logged-on user and false if this is the user's first interaction with the page.
Typically, the need to determine whether or not the current HTTP request is indeed a postback is most helpful when you wish to perform a block of code only the first time the user accesses a given page. For example, you may wish to populate an ADO.NET DataSet when the user first accesses an *.aspx file and cache the object for later use. When the caller returns to the page, you can avoid the need to hit the database unnecessarily (of course, some pages may require that the DataSet is always updated upon each request, but that is another issue). We will see this property in action at various points during the
remainder of this chapter, but here is a simple example:
C# and the .NET Platform, Second Edition
private |
by Andrew Troelsen |
ISBN:1590590554 |
void Page_Load(object sender, System.EventArgs e) |
||
{ |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
// |
Only C#readlanguagethe andDB thenthequickly moves to key technical and |
|
// |
very architecturalfirst timeissuestheforuser.NET developers. |
|
// |
comes to this page. |
|
if(!IsPostBack)
Table of {Contents
// Populate DataSet and cache it!
C# and the .NET Platf rm, Second Edition
}
Introduction
// Use precached DataSet.
Part One - Introducing C# and the .NET Platform
}
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
At this point you should feel quite confident with the architecture of an ASP.NET Page type and the role of
Chapter 4 - Object-Oriented Programming with C#
the System.Web.UI.Page base class. Now that you have such a foundation, we can turn our attention to
Chapter 5 - Exceptions and Object Lifetime the role of ASP.NET Web controls.
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .ASPNET latform,.NET WebSecondControlsEdition
by Andrew Troelsen |
ISBN:1590590554 |
One major benefit of ASP.NET is the ability to assemble the user interface of your Web pages using the
Apress © 2003 (1200 pages)
GUI types defined in the System.Web.UI.WebControls namespace. These controls (which go by the names
This comprehensive text starts with a brief overview of the
server controls,WebC# languagecontrols,andor WebthenFormquicklycontrolsmoves) areto kextremelyy technicalhelpfuland in that they automatically generate the necessaryarchitecturalHTMLissuestags for .theNETrequestingdev lopersbrowser. and expose a set of events that may be processed on the Web server. Furthermore, because each ASP.NET control has a corresponding class in the System.Web.UI.WebControls namespace, it can be programmatically manipulated from your *.aspx file
Table of Contents
(within a <script> block) as well as within the associated class defined in the code behind file.
C# and the .NET Platform, Second Edition
As you would suspect, each of the ASP.NET Web controls are arranged within a class hierarchy, as seen in
Introduction
Figure 18-20.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter |
Programming |
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Figure 18-20: The ASP.NET Web controls
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
As you have seen, when you configure a given Web control using the VS .NET Properties window, your
Chapter 20 - XML Web Services
edits are written directly to the *.aspx file as a series of name/value pairs. In this regard, Web Form
Index
development is a bit different from that of Windows Forms development, given that under the Windows ListFormsof Figuresmodel, modifications made on the Properties window appear within the InitializeComponent() helper
Listmethodof Tables. As you have also seen, like a Windows Forms application, the InitializeComponent() method defined in your code behind file is still used to rig up events to specific event handlers.
To illustrate, if you add a new TextBox widget (named myTextBox) to the designer of a given *.aspx file and change the BorderStyle, BorderWidth, BackColor, and BorderColor properties using VS .NET, the opening <asp:textbox> tag is modified as follows:
<asp:textbox id=myTextBox runat="server" BorderStyle="Ridge"BorderWidth="5px"
BackColor="PaleGreen"BorderColor="DarkOliveGreen" >
</asp:TextBox>
In the code behind file, you will find a member variable whose name is identical to the ID element defined in the *.aspx file. Using this member variable, you are able to interact with the same properties as you would expect:
public class MainPage : System.Web.UI.Page
{ |
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
|
|
// Note that the name of the member variable Is identical to |
Apress © 2003 (1200 pages) |
|
// the ID value of the *.aspx declaration. |
|
This comprehensive text starts wi h a brief overview of the |
|
protected System.Web.UI.WebControls.TextBox |
myTextBox; |
C# language and then quickly moves to key technical and
...
architectural issues for .NET developers. private void SomeHelperFunction()
{
// Interact with Web widget.
Table of Contents
myTextBox.BackColor = Color.Red;
C# and the .NET Platform, Second Edition
Response.Write(String.Format("Border color Is: {0}",
Introduction
myTextBox.BorderColor.ToString()));
Part One - Introducing C# and the .NET Platform
}
Chapter 1 - The Philosophy of .NET
}
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
ChaptAs seenr 3 in-FigureC# Language18-20, allFundamof thentalsASP.NET server-side controls ultimately derive from a common base
Chclasspternamed4 - ObjectSystem-Oriented.Web.UIProgramming.WebControlswith.WebControlC# . WebControl in turn derives from
ChapSystemr 5.Web- Exceptions.UI.WebControlsa d Object.ControlLifetime(which derives from System.Object). Control and WebControl each Chapterdefine a6 number- Int facesof propertiesand Collectionscommon to all server-side controls. To help gain an understanding of your
inherited functionality, let's check out the core functionality provided by each of these key base classes. But
Chapter 7 - Callback Interfaces, Delegates, and Events
first, let's formalize what it means to handle a server-side event.
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
ChapterQualifying9 - Understandingthe Role.NETofAssembliesServer-Side Event Handling
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Given the current state of the World Wide Web, it is impossible to avoid the fundamental nature of
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
browser/Web server interaction. Whenever these two entities communicate, there is always an underlying,
Part Four - Leveraging the .NET Libraries
stateless, HTTP request-and-response cycle. While ASP.NET server controls do a great deal to shield you
Chapter 12 - Object Serialization and the .NET Remoting Layer
from the details of the raw HTTP protocol, always remember that treating the Web as an event-driven entity
Chapter 13 - Building a Better Window (Introducing Windows Forms)
is just a magnificent smoke-and-mirror show provided by the CLR, and is not semantically identical to a
Chapter 14 - A Better Painting Framework (GDI+)
Windows-based user interface.
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Given this, be aware that although the System.Windows.Forms and System.Web.UI.WebControls
Chapter 17 - Data Access with ADO.NET
namespaces define numerous types with the same simple name (Button, TextBox, and so on), they do not
Part Five - Web Applications and XML Web Services
expose the same set of events. For example, there is no way to handle a server-side MouseMove event
Chapter 18 - ASP.NET Web Pages and Web Controls
when the user moves the cursor over a Web Form Button type. Obviously this is a good thing. (Who wants Chato postter 19back- ASPto the.NETserverWeb Applicationseach time the mouse moves?) When you need to handle such logic, you will
Chapterneed to20simply- XMLemitWebtheServicescorrect client-side JavaScript. Furthermore, many Web widget events expose an
Indeventx that may seem to be identical in nature to the Windows Forms equivalent (such as the Change event Listof aofTextBox),Figures but acts quite differently under the hood.
List of Tables
The bottom line is that a given ASP.NET Web control will expose a limited set of events, all of which ultimately correspond to a postback to the Web server. For example, a System.Web.UI.WebControl.Button type exposes a Click event that results in a postback to a specific method on the hosting Page-derived type. The System.Web.WebControl.TextBox type defines a Changed event that will entail a postback when the user tabs off the current control to a new control.
The AutoPostBack Property
It is also worth pointing out that many of the ASP.NET Web controls support a property named AutoPostBack (specifically, the CheckBox, RadioButton, and TextBox controls as well as any widget that derives from the abstract ListControl type). By default, this property is set to false, which as you would guess disables the automatic posting of server-side events (even if you have indeed rigged up the event in the code behind file). In many cases, this is the exact behavior you require.
However, if you do wish to cause any of these widgets to post back to a server-side event handler, simply set the value of AutoPostBack to true. This technique can be helpful if you wish to have the state of one
widget automatically populate another widget.
C# and the .NET Platform, Second Edition
To illustrate, createby Andra WebwapplicationTroelsen that contains a single TextBoxISBN:1590590554and a single ListBox control. Now, handle the TextChangedApress © event2003 (1200of thepages)TextBox, and within the server-side event handler, populate the ListBox with the currentThis comprehensivevalue in the TextBoxt xt starts(gotwiththat?):a brief overview of the
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
private void txtPostBackBox_TextChanged(object sender, System.EventArgs e)
{
lstCharacters.Items.Add(txtPostBackBox.Text);
Table of Contents
}
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
If you run the application as is, you will find that as you type in the TextBox, nothing happens. Furthermore, if
Chapter 1 - The Philosophy of .NET
you were to type in the TextBox and tab to the next control, nothing happens. The reason is that the
Chapter 2 - Building C# Applications
AutoPostBack property of the TextBox is set to false by default. If you set this property to true:
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
<asp:TextBox id="txtPostBackBox"
Chapter 4 - Object-Oriented Programming with C#
style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 48px"
Chapter 5 - Exceptions and Object Lifetime runat="server"AutoPostBack="True">
Chapter 6 - Interfaces and Collections
</asp:TextBox>
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
you will find that when you tab off the TextBox, the ListBox is automatically populated with the current value
Chapter 9 - Understanding .NET Assemblies
via the server-side event handler. Beyond the need to populate the items of one widget based on the value
Chapter 10 - Processes, AppDomains, Contexts, and Threads
of another widget, you will typically not need to alter the state of a widget's AutoPostBack property.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Key MembersC# andofthethe.NETSystemPla for .,WebSecond.UIEdition.Control Type
by Andrew Troelsen |
ISBN:1590590554 |
The System.Web.UI.Control base class defines various properties, methods, and events that allow a given
Apress © 2003 (1200 pages)
page to interact with its set of contained controls, enable (or disable) view state, and interact with the event set
This comprehensive text starts with a brief overview of the
of a widget's lifetimeC# .languageTable 18and-11thendocumentsquickly movessome oftothekeykeytechnicalproperties,and methods, and events to be aware of.
architectural issues for .NET developers.
Table 18-11: Select Members of System.Web.UI.Control
|
|
|
|
|
|
TableInterestingof Contents Member of |
|
Meaning in Life |
|
||
C#System.Web.UI.Controland the .NET Platform, Second Edition |
|
|
|
||
|
|
|
|
|
|
|
Introduction |
|
This property gets a ControlCollection object that |
|
|
|
Controls |
|
|
|
|
Part One - Introducing C# and the .NET Platform |
|
||||
Chapter 1 |
- The Philosophy of .NET |
represents the child controls for a specified server control in |
|
||
the UI hierarchy. |
|
||||
|
|
|
|
|
|
|
Chapter 2 |
- Building C# Applications |
|
|
|
|
|
|
|
||
PartEnableViewStateTwo - The C# Programming Language |
|
This property gets or sets a value indicating whether the |
|
||
Chapter 3 |
- C# Language Fundamentals |
|
server control persists its view state, and the view state of |
|
|
|
Chapter 4 |
- Object-Oriented Programming |
|
any child controls it contains, to the requesting client. |
|
|
with C# |
|
|||
|
|
|
|
||
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
This property gets or sets the programmatic identifier |
|
|
ID |
|
|
|
|
|
Chapter 6 |
- Interfaces and Collections |
|
assigned to the server control. |
|
|
|
|
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, |
|
and Events |
|
|
Page |
- Advanced C# Type Construction |
|
This property gets a reference to the Page instance that |
|
|
Chapter 8 |
|
Techniques |
|
|
|
|
|
|
contains the server control. |
|
Part Three - Programming with .NET Assemblies |
|
||||
|
Chapter 9 |
- Understanding .NET Assemblies |
|
This property gets a reference to the server control's parent |
|
|
Parent |
|
|
|
|
|
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
|
||
|
|
|
|
control in the page control hierarchy. |
|
|
|
|
|
|
|
|
Chapter 11 |
- Type Reflection, Late Binding, |
and Attribute-Based Programming |
|
|
|
Visible |
|
|
This property gets or sets a value that indicates whether a |
|
Part Four - Leveraging the .NET Libraries |
|
server control is rendered as UI on the page. |
|
||
|
|
|
|
|
|
|
Chapter 12 |
- Object Serialization and the .NET |
Remoting Layer |
|
|
|
|
||||
|
ChapterDataBind()13 - Building a Better Window (IntroducingBindsWindowsa data sourceForms)to the invoked server control and all its |
|
|||
|
Chapter 14 |
- A Better Painting Framework (GDI+)child controls. |
|
||
|
|
|
|
|
|
|
Chapter 15 |
- Programming with Windows Forms Controls |
|
||
|
HasControls() |
|
Determines if the server control contains any child controls. |
|
This event occurs when the server control binds to a data
source.
Part Five - Web Applications and XML Web Services
|
Chapter 18 |
- ASP.NET Web Pages and Web |
|
Controls |
|
Init |
|
|
Recall that this event occurs when the server control is |
|
Chapter 19 |
- ASP.NET Web Applications |
|
initialized, which is the first step in its life cycle. |
|
|
|
|
Chapter 20 - XML Web Services
Load
Index
List of Figures
ListUnloadof T bles
Recall that this event occurs when the server control is loaded into the Page object.
Recall that this event occurs when the server control is unloaded from memory.
Fun with the Control Base Class: Enumerating Contained Controls
The first aspect of System.Web.UI.Control we will examine is the fact that all controls inherit a property named Controls that works in conjunction with the closely related HasControls() method. Much like a Windows Forms application, the Controls property provides access to a strongly typed collection of Web Form control types.
Like any collection, you have the ability to add, insert, and remove items dynamically at runtime.
To illustrate, assume you have a new ASP.NET Web Application project and an *.aspx file that maintains a Panel type that contains three other types (say, a TextBox, HyperLink, and Button). Here are the widget's declarations:
<asp:Panel id="thePanel" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute;
TOP: 8px" runat="server" Width="500px" Height="110px" BorderStyle="Ridge">
C# and the .NET Platform, Second Edition
<P>This panel contains three controls</P>
by Andrew Troelsen ISBN:1590590554
<P> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
Apress © 2003 (1200 pages)
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
This comprehensive text starts with a brief overview of the
<asp:HyperLink id="HyperLink1" runat="server">HyperLink</asp:HyperLink></P>
</asp:Panel> C# language and then quickly moves to key technical and architectural issues for .NET developers.
Next, place a Label widget outside the scope of the Panel to hold the page's output. The associated UI can be
Table of Contents seen in Figure 18-21.
C# and the .NET Platform, Second Edition
Introduction
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
ChapterFigure8 - 18Advanced-21: PanelC# withTypecontainedConstructioncontrolsTechniques
Part Three - Programming with .NET Assemblies
Now, assume in your Page_Load() event, you wish to obtain a list of all the controls contained within the Panel
Chapter 9 - Understanding .NET Assemblies
(with the assistance of a private helper function) and display the results on a Label type. Ponder the following
Chapter 10 - Processes, AppDomains, Contexts, and Threads
code update:
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
public class PanelPage : System.Web.UI.Page
Chapter 12 - Object Seria ization and the .NET Remoting Layer
{
Chapter 13 - Building a Better Window (Introducing Windows Forms)
...
Chapter 14 - A Better Painting Framework (GDI+)
private void Page_Load(object sender, System.EventArgs e)
Chapter 15 - Programming with Windows Forms Controls
{
Chapter 16 - The System.IO Namespace
// Show the controls on a panel.
Chapter 17 - Data Access with ADO.NET
ListControlsOnPanel();
Part Five - Web Applications and XML Web Services
}
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
public void ListControlsOnPanel()
Chapter 20 - XML Web Services |
||
{ |
|
|
Index |
string theInfo; |
|
List of Figures |
||
theInfo = String.Format("Has controls? {0}<br>", |
||
List of Tables |
thePanel.HasControls()); |
ControlCollection |
myCtrls = thePanel.Controls; |
foreach(Control c |
in myCtrls) |
{ |
|
if(c.GetType() != typeof(System.Web.UI.LiteralControl)) |
|
{ |
+= "***************************<br>"; |
theInfo |
|
theInfo |
+= String.Format("Control Name? {0}<br>", |
c.ToString()); |
|
theInfo |
+= String.Format("ID? {0}<br>", c.ID); |
theInfo |
+= String.Format("Control Visible? {0}<br>", |
c.Visible); |
|
theInfo |
+= String.Format("ViewState? {0}<br>", |
c.EnableViewState);
}
}
lblControlInfo.Text = theInfo;
|
} |
C# and the .NET Platform, Second Edition |
|
|
... |
by Andrew Troelsen |
ISBN:1590590554 |
||
|
||||
|
|
|
}Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Here, the ListControlsOnPanel() helper function iterates over each WebControl maintained on the Panel and performs a check to see if the current type is a System.Web.UI.LiteralControl. This type is used to represent
literal HTML tags and content (such as <br>, text literals, and so on). If you do not make this sanity check, you
Table of Contents
might be surprised to find a total of seven types in the scope of the panel (given the *.aspx declaration seen
C# and the .NET Platform, Second Edition
previously). Assuming the type is not literal HTML content, you then print out some various statistics about the
Introduction
widget.Figure 18-22 shows the output.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter |
Programming |
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part Five - Web Applications and XML Web Services
Figure 18-22: Enumerating contained widgets
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Fun with the Control Base Class: Dynamically Adding (and Removing)
Index ListControlsf Figures
List of Tables
Now, what if you wish to modify the contents of a Panel at runtime? The process should look very familiar to you, given your work with Windows Forms earlier in this text. Let's update the page to support one button that dynamically adds five new TextBox types to the Panel, and another that clears out the entire control set. The Click event handlers for each are shown here:
private void btnAddTextBoxes_Click(object sender, System.EventArgs e)
{
for(int i = 0; i < 5; i++)
{
//Assign a name so we can get
//the text value out later
//using the HttpRequest.QueryString()
//method.
TextBox t = new TextBox();
t.ID = string.Format("newTextBox{0}", i);
thePanel.Controls.Add(t);
C# and the .NET Platform, Second Edition
}
by Andrew Troelsen |
ISBN:1590590554 |
ListControlsOnPanel(); |
|
}Apress © 2003 (1200 pages)
|
This comprehensive ext starts with a brief overview of the |
private void btnRemoveAllItems_Click(object sender, System.EventArgs e) |
|
{ |
C# language and then quickly moves to key technical and |
architectural issues for .NET developers. |
|
|
thePanel.Controls.Clear(); |
|
ListControlsOnPanel(); |
}
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Notice that you assign a unique ID to each TextBox (e.g., newTextBox1, newTextBox2, and so on) in order to
Part One - Introducing C# and the .NET Platform
obtain their contained text programmatically using the HttpRequest.Form collection (seen momentarily). Given
Chapter 1 - The Philosophy of .NET
that you dynamically add these items to the Panel, you cannot obtain their values using page-level member
Chapter 2 - Building C# Applications
variables, as they have no formal declaration in the *.aspx file!
Part Two - The C# Programming Language
To obtain the values within these dynamically generated TextBoxes, update your UI with an additional Button
Chapter 3 - C# Language Fundamentals
and Label type. Within the Click event handler for the Button, loop over each item contained within the
Chapter 4 - Object-Oriented Programming with C#
HttpRequest.NameValueCollection type (accessed via HttpRequest.Form) and concatenate the textual
Chapter 5 - Exceptions and Object Lifetime
information to a locally scoped System.String. Once you have exhausted the collection, assign this string to the
Chapter 6 - Interfaces and Collections
Text property of the new Label widget named lblTextBoxText:
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
private void btnGetTextBoxValues_Click(object sender, System.EventArgs e)
Part Three - Programming with .NET Assemblies
{
Chapter 9 - Understanding .NET Assemblies
// Just in case the panel is empty
Chapter 10 - Processes, AppDomains, Contexts, and Threads
string textBoxValues = "";
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
for(int i = 0; i < Request.Form.Count; i++)
Part Four - Leveraging the .NET Libraries
{
Chapter 12 - Object Serialization and the .NET Remoting Layer textBoxValues +=
Chapter 13 - Building a Better Window (Introducing Windows Forms) string.Format("<li>{0}</li><br>", Request.Form[i]);
Chapter 14 - A Better Painting Framework (GDI+)
}
Chapter 15 - Programming with Windows Forms Controls lblTextBoxText.Text = textBoxValues;
Chapter 16 - The System.IO Namespace
}
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
ChapterWhen you18 -runASPthe.NETapplication,Web PagesyouandwillWebfindControlsthat you are able to view the context of each text box, including a Chaptratherr long19 - (unreadable)ASP.NET W stringApplications. This string contains the view state for each widget on the page and will be
examined later in the text. Also, you will notice that once the request has been processed, the ten new text
Chapter 20 - XML Web Services
boxes disappear. Again, the reason has to do with the stateless nature of HTTP. If you wish to maintain these
Index
dynamically created TextBoxes between postbacks, you would need to persist these objects using ASP.NET
List of Figures
state programming techniques (examined in the next chapter).
List of Tables
Note The process of dynamically adding, deleting, and modifying the items in a Panel should drive the point home that one key initiative of ASP.NET was to make the process of building a Web application look and feel much like the process of building a Windows application. Although very intriguing, a simpler approach would be to place all possible widgets in the Panel at design time, and then set the Visible property to false for the items you do not wish to display.
In any case, at this point you have seen how all ASP.NET Web controls inherit a Controls property that is used to access internal child controls. Using this collection, you are able to dynamically add, delete, and modify items on the fly.
SOURCE |
The DynamicCtrls files are included under the Chapter 18 subdirectory. |
CODE
Key MembersC# andofthethe.NETSystemPla for .,WebSecond.UIEdition.WebControl Type
by Andrew Troelsen |
ISBN:1590590554 |
As you can tell, the Control type provides a number of non-GUI-related behaviors. On the other hand, the
Apress © 2003 (1200 pages)
WebControl base class provides a graphical polymorphic interface to all Web widgets as suggested in
This comprehensive text starts with a brief overview of the Table 18-12. C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Table 18-12: Properties of the WebControl Base Class
|
|
|
|
|
|
|
|
|
TableWebControlof Contents |
|
Meaning in Life |
|
|
|
|||
C#Propertyand the .NET Platform, Second Edition |
|
|
|
|||||
|
|
|
|
|
|
|
||
|
|
Introduction |
|
Gets or sets the background color of the Web control |
|
|
|
|
|
|
BackColor |
|
|
|
|
||
Part One - Introducing C# and |
the .NET Platform |
|
|
|
||||
|
|
|
||||||
ChapterBorderColor1 - The Philosophy |
ofGets.NETor sets the border color of the Web control |
|
|
|
||||
|
|
|
|
|
|
|
||
|
|
Chapter 2 |
- Building C# Applications |
|
|
|
||
|
|
BorderStyle |
|
Gets or sets the border style of the Web control |
|
|
|
|
Part Two - The C# Programming |
|
Language |
|
|
|
|||
|
|
|
|
|||||
ChapterBorderWidth3 - C# Language |
|
FundamentalsGets or sets the border width of the Web control |
|
|
|
|||
|
|
|
|
|
|
|
||
|
|
Chapter 4 |
- Object-Oriented |
|
Programming with C# |
|
|
|
|
|
Enabled |
|
|
Gets or sets a value indicating whether the Web control is enabled |
|
|
|
|
|
Chapter 5 |
- Exceptions and |
|
Object Lifetime |
|
|
|
|
|
|
|
|
|
|||
|
ChapterCssClass6 - Interfaces and |
|
CollectionsAllows you to assign a cascading style sheet to a Web widget |
|
|
|
||
|
|
|
|
|
|
|
||
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
|
||
|
|
Font |
|
|
Gets font information for the Web control |
|
|
|
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
|
||
|
|
|
|
|||||
PartForeColorThree - Programming withGets.NETorAssembliessets the foreground color (typically the color of the text) of the |
|
|
|
|||||
|
Chapter 9 |
- Understanding |
|
.NETWebAssembliescontrol |
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
|
|
|
||
|
|
Height Width |
|
Get or set the height and width of the Web control |
|
|
|
|
|
|
Chapter 11 |
- Type Reflection, |
|
Late Binding, and Attribute-Based Programming |
|
|
|
|
|
|
|
|||||
PartTabIndexFour - Leveraging the .NETGetsLibrariesor sets the tab index of the Web control |
|
|
|
|||||
|
|
|
|
|
|
|
||
|
|
Chapter 12 |
- Object Serialization |
and the .NET Remoting Layer |
|
|
|
|
|
|
Tool |
|
|
Gets or sets the tool tip for the Web control to be displayed when the |
|
|
|
|
Chapter 13 |
- Building a Better |
Window (Introducing Windows Forms) |
|
|
|
||
|
|
|
|
|
cursor is over the control |
|
|
|
|
Chapter 14 |
- A Better Painting Framework (GDI+) |
|
|||||
Chapt r 15 |
- Programming with Windows Forms Controls |
|||||||
|
I'd bet that almost all of these properties are self-explanatory, so rather than drill through the use of all |
|||||||
Chapt r 16 |
- The System.IO |
|
|
|
|
|
||
|
these properties, let's shift Namespacegears bit and check out a number of ASP.NET Web Form controls in action. |
|||||||
Chapter 17 |
- Data Access with ADO.NET |
|||||||
Part Five - Web Applications and XML Web Services |
||||||||
Chapter 18 |
- ASP.NET Web Pages and Web Controls |
|||||||
Chapter 19 |
- ASP.NET Web Applications |
|||||||
Chapter 20 |
- XML Web Services |
|||||||
Index |
|
|
|
|
|
|
List of Figures
List of Tables
Select ExamplesC# and theof.NETASPlatform,.NET SecondWebFormEdition Controls
by Andrew Troelsen |
ISBN:1590590554 |
The types in the System.Web.UI.WebControls can be broken down into four broad categories:
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
Simple controls
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
(Feature) Rich controls
Data-centric controls
Table of Contents
C# and the .NET Platform, Second Edition
Input validation controls
Introduction
Thesimple controls are so named because they are ASP.NET Web controls that map to standard HTML widge
Part One - Introducing C# and the .NET Platform
(buttons, lists, hyperlinks, image holders, tables, and so forth). Next we have a small set of controls named the
Chapter 1 - The Philosophy of .NET
rich controls for which there is no direct HTML equivalent (such as the Calendar and AdRotator). The data-
Chapter 2 - Building C# Applications
centriccontrols are widgets that are typically populated via a given data connection. The best (and most
Part Two - The C# Programming Language
complex) example of such a control would be the ASP.NET DataGrid. Other members of this category include
Chapter 3 - C# Language Fundamentals
"repeater" controls and the lightweight DataList. Finally, the validation controls are server-side widgets that
Chapter 4 - Object-Oriented Programming with C#
automatically emit client-side JavaScript, for the purpose of form field validation.
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
In the pages that follow, I will not walk through each and every member of each and every control within the
ChaptSystemr 7 - Callback Interfaces, Delegates, and Events
.Web.UI.WebControls namespace. Given your work with Windows Forms controls earlier in this book, y Chaptershould8feel- rightAdvancedat homeC# TypewhenConstructionyou manipulateTechniqutheseswidgets. Just remember that while Windows Forms types
PartencapsulateThree - Programmingthe raw Win32withAPI.NETfromAssembliesview, Web Form controls encapsulate the generation of raw HTML tags. I
Chapteryou wish9 to- followUnderstandingalong, create.NET Assembliesa new ASP.NET Web application named FunWithControls.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterWorking11 - TypewithReflection,the ListBoxate Binding,Controland A t ibute-Based Programming
Part Four - Leveraging the .NET Libraries
ChapterTo begin,12 let's- ObjectexamineSerializationsome ofandthetheintrinsic.NET ResimpleotingcontrolsLayer . These types basically map to a standard HTML
Chaptwidgetr 13counterpart- Building. Fora Betterexample,Windowif you(Introducingwish to displayWindowsa staticForms)list of items for the end user, you can construct a
ChapterListBox14type- AusingBettera Paintingset of relatedFrameworkListItems:(GDI+)
Chapter 15 - Programming with Windows Forms Controls
Ch<asp:pter 16 - The System.IO Namespace
ListBox id=ListBox1 runat="server" Width="86" Height="69">
Chapter <asp:17 - DataListItemAccess withValue="BMW">BMW</asp:ListItem>ADO.NET
Part Five<asp:- WebListItemApplica ionsValue="Jetta">Jetta</asp:ListItem>and XML W b Services
Chapter <asp:18 - ASPListItem.NET W b PagesValue="Colt">Colt</asp:ListItem>and Web Contr
Chapter <asp:19 - ASPListItem.NET Web AppValue="Grandications Am">Grand Am</asp:ListItem>
</asp:ListBox>
Chapter 20 - XML Web Services
Index
List of Figures
When the controls are processed by the ASP.NET runtime, the resulting HTML returned to the browser looks
List of Tables something like this:
<select name="ListBox1" id="ListBox1" size="5" style="height:69px;width:86px;">
<option value="BMW">BMW</option>
<option value="Jetta">Jetta</option>
<option value="Colt">Colt</option>
<option value="Grand Am">Grand Am</option>
</select>
Note Understand that when you declare an ASP.NET Web control within the scope of an *.aspx file (using ListItem types), you have basically defined a fixed set of items. If you wish to dynamically populate a li add the items using the ListBox.Items.Add() method within the code behind file.
Working with Radio Buttons
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Radio button types tend to work as a group in which only one item in the group can be selected at a given time.
Apress © 2003 (1200 pages)
For example, if you are interested in creating a set of mutually exclusive radio buttons, your goal is to ensure th
This comprehensive text starts with a brief overview of the
the GroupName of each ASP.NET RadioButton is set to the same friendly name:
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
<asp:RadioButton id=RadioHome runat="server"
Text="Contact me at home" GroupName="ContactGroup">
Table of Contents
</asp:RadioButton>
C#<p><asp:RadioButtonand the .NET Platform, Secondid=RadioWorkEdition runat="server"
IntroductionText="Contact me at work" GroupName="ContactGroup">
Part</asp:RadioButton>One - Introducing C# and the .NET Platform
Chapter<p><asp:RadioButton1 - The Philosophy ofid=RadioDontBother.NET runat="server"
Text="Don't bother me..." GroupName="ContactGroup">
Chapter 2 - Building C# Applications
</asp:RadioButton>
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Unlike a Windows Forms application, ASP.NET RadioButton types are not grouped together by virtue of being
Chapter 6 - Interfaces and Collections
placed within a containing GroupBox. In fact, RadioButtons that share the same GroupName do not even need
Chapter 7 - Callback Interfaces, Delegates, and Events
be placed in a similar location on the page. However, if you do wish to simulate such a GUI, you can choose to
Chapter 8 - Advanced C# Type Construction Techniques
make use of the RadioButtonList type, which like a ListBox maintains a set of ListItem types:
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
<asp:RadioButtonList id="carRadioButtonList"
Chapter 10 - Processes, AppDomains, Contexts, and Threads
style="Z-INDEX: 102; LEFT: 24px; POSITION: absolute; TOP: 24px"
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming runat="server" Width="96px" BorderStyle="Solid"
Part Four - Leveraging the .NET Libraries
BorderWidth="1px"BorderColor="Black">
Chapter 12 - Object Serialization and the .NET Remoting Layer
<asp:ListItem Value="Colt">Colt</asp:ListItem>
Chapter 13 - Building a Better Window (Introducing Windows Forms)
<asp:ListItem Value="BWM">BWM</asp:ListItem>
Chapter 14 - A Better Painting Framework (GDI+)
<asp:ListItem Value="Audi TT">Audi TT</asp:ListItem>
Chapter 15 - Programming withValue="Viper">Viper</asp:ListItem>Windows Fo ms Controls
<asp:ListItem
Chapter</asp:RadioButtonList>16 - The Sys em.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
When you make use of a RadioButtonList, the items are automatically mutually exclusive. Also, if you enable th
Chapter 18 - ASP.NET Web Pages and Web Controls
AutoPostBack behavior and handle the SelectedIndexChanged event, you are able to obtain the value of the
Chapter 19 - ASP.NET Web Applications
currently selected ListItem using the SelectedValue property:
Chapter 20 - XML Web Services
Index
private void carRadioButtonList_SelectedIndexChanged(object sender,
List of Figures
System.EventArgs e)
List of Tables
{
//NOTE! If you would rather obtain the specific ListItem widget,
//make use of the SelectedItem property.
lblCarSelection.Text = carRadioButtonList.SelectedValue;
}
Of course, even if you do not enable the AutoPostBack property for the widget, you are still able to obtain the selected value in another server-side event handler.
Creating a Scrollable, Multiline TextBox
Another common widget is a multiline text box. As you would expect, configuring a text box to function in this wa is simply a matter of adding the correct attribute set to the opening <asp:TextBox> tag. Consider this example:
<asp:TextBox id=TextBox1 runat="server" Width="183" Height="96"
C# and the .NET Platform, Second Edition
TextMode="MultiLine" BorderStyle="Ridge">
by Andrew Troelsen |
ISBN:1590590554 |
</asp:TextBox> |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
|
C# language and th |
n quickly moves to key technical and |
When you set the TextMode attribute to MultiLine, the TextBox automatically displays a vertical scroll bar when
architectural issues for .NET developers. the content is larger than the display area.
Note If you wish to build a password-style TextBox, simply set the TextMode property to Password.
Table of Contents
C# and the .NET Platform, Second Edition
Building a Simple HTML Table
Introduction
Part One - Introducing C# and the .NET Platform
The final simple control we will examine here is the Table type. This widget can be useful when you wish to emi
Chapter 1 - The Philosophy of .NET
an HTML table that is not based on a database connection (and would rather not emit all the HTML table tags b
Chand)pter 2 - Building C# Applications
. First, if you have a table that will always maintain the exact same information, you can build the table PartcompletelyTwo - TheatC#designProgrammingtime withinLanguagethe *.aspx file. Notice how the ASP.NET Table widget is composed of a set of Chapterrows, each3 - ofC#whichLanguagecontainsFundamsetntalsof cells. Also note that the rows and cells of a Table are represented by the
ChTableRowpt r 4 -andObjectTableCell-Orientedtypes,Programmingrespectively:with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
<asp:Table id="salesPeople"
Chapter 7 - Callback Interfaces, Delegates, and Events
style="Z-INDEX: 108; LEFT: 32px; POSITION: absolute; TOP: 304px"
Chapterrunat="server"8 - AdvancedWidth="216px">C# Type Construction Techniques
Part Three<asp:TableRow>- Programming with .NET Assemblies
Chapter 9 - Understanding<asp:TableCell.NET AssembliesText="Sale Person"></asp:TableCell>
Chapter 10 - Proce<asp:TableCellses, AppDomains,Text="EmployeeCon exts, and Thr adsID"></asp:TableCell>
Chapter </asp:TableRow>11 - Type Refl ction, Late Binding, and Attribute-Based Programming
<asp:TableRow>
Part Four - Leveraging the .NET Libraries
<asp:TableCell Text="West Cost"></asp:TableCell>
Chapter 12 - Object Serialization and the .NET Remoting Layer
<asp:TableCell Text="2"></asp:TableCell>
Chapter 13 - Building a Better Window (Introducing Windows Forms)
</asp:TableRow>
Chapter 14 - A Better Painting Framework (GDI+)
<asp:TableRow>
Chapter 15 - Programming with Windows Forms Controls
<asp:TableCell Text="McCabe Jr."></asp:TableCell>
Chapter 16 - The System.IO Namespace
<asp:TableCell Text="1"></asp:TableCell>
Chapter 17 - Data Access with ADO.NET
</asp:TableRow>
Part Five - Web Applications and XML Web Services
<asp:TableRow>
Chapter 18 - ASP.NET Web Pages and Web Controls
<asp:TableCell Text="McCabe Sr."></asp:TableCell>
Chapter 19 - ASP.NET Web Applications
<asp:TableCell Text="3"></asp:TableCell>
Chapter 20 - XML Web Services
</asp:TableRow>
Index
</asp:Table>
List of Figures
List of Tables
If your Table needs to be dynamically generated, you can simply place an empty ASP.NET Table widget and build it programmatically in the code behind file. For example the Button Click event handler creates the table seen in Figure 18-23 (assume you have added an ASP.NET Table widget named myAutoGenTable to your designer).
Second Edition
ISBN:1590590554
with a brief overview of the
moves to key technical and
developers.
Table
C# and
Part
Chapter
Figure 18-23: A dynamically generated HTML table
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter |
3 |
- C# Language Fundamentals |
sender, System.EventArgs e) |
Chapterprivate4 |
-voidObjectbtnBuildTable-Oriented Programming_Click(objectwith C# |
||
Chapter{ |
5 |
- Exceptions and Object Lifetime |
|
Chapter //6 |
-AutoInterfaces-generateand Collectionsthe table |
|
|
Chapter |
for(int i = 0; i < 3; i++) |
|
|
7 |
- Callback Interfaces, Delegates, and Events |
|
|
Chapter |
{ |
- Advanced C# Type Construction Techniques |
|
8 |
|
||
|
|
TableRow r = new TableRow(); |
|
Part Three - Programming with .NET Assemblies |
|
||
|
|
for(int j = 0; j < 3; j++) |
|
Chapter |
9 |
- Understanding .NET Assemblies |
|
|
|
{ |
|
Chapter |
10 |
- Processes, AppDomains, Contexts, and Threads |
|
|
|
TableCell c = new TableCell(); |
|
Chapter |
11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
|
|
|
c.Text = string.Format("Row {0}, Column {1}", |
Part Four - Leveraging the .NET Libraries
i+1, j+1);
Chapter 12 - Object Serialization and the .NET Remoting Layer
.Cells.Add(c);
Chapter 13 - Building} a Better Window (Introducing Windows Forms)
Chapter 14 - A myAutoGenTableBetter Painti g Framew.Rorkws(GDI+).Add(r);
Chapter }15 - Programming with Windows Forms Controls
}
Chapter 16 - The System.IO Namespace Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
ChaptTherFeature19 - ASP.NET-RichWeb ApplicationsControls
Chapter 20 - XML Web Services
Rich controls are also widgets that emit HTML to the HTTP response stream. The difference between these
Index
types and the set of intrinsic controls is that they have no direct HTML counterpart. Table 18-13 describes two
List of Figures
rich controls.
List of Tables
Table 18-13: Rich WebControl Widgets
|
|
|
|
|
|
WebForm Rich |
|
Meaning in Life |
|
|
Control |
|
|
|
|
|
|
|
|
|
AdRotator |
|
This control allows you to randomly display text/images using a |
|
|
|
|
corresponding XML configuration file. |
|
|
|
|
|
|
|
Calendar |
|
This control returns HTML that represents a GUI-based calendar. |
|
|
|
|
|
|
Working with the Calendar Control
The Calendar control is a widget for which there is no direct HTML equivalent. Nevertheless, this type has been designed to return a batch of HTML tags that simulate such an entity. For example, suppose you place a Calendar control on your WebForm as shown here:
C# and the .NET Platform, Second Edition |
|
<asp:Calendar id=Calendar1 runat="server"></asp:Calendar> |
|
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
Once you run thisThispage,comprehensiveyou find thattexta hugestartsamountwith a ofbriefrawoverviewHTML hasof thebeen emitted to the browser. Like its
counterpart,C# langu ge and then quickly moves to key technhighlycal and
Windows Forms the ASP.NET Calendar control is customizable. One member of interest is
architectural issues for .NET developers.
the SelectionMode property. By default, the Calendar control only allows the end user to select a single day (e. SelectionMode = "Day"). You can change this behavior by assigning this property to any of the following
alternatives:
Table of Contents
C# andNone:the .NET Platform, Second Edition
No selection can be made (e.g., the Calendar is just for display purposes).
Introduction
DayWeek: User may select a single day or an entire week.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
DayWeekMonth: User may select a single day, an entire week, or an entire month.
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
For example, if you choose DayWeekMonth, the returned HTML renders an additional leftmost column (to allo
Chapter 3 - C# Language Fundamentals
the end user to select a given week) as well as a selector in the upper left of the widget (to allow the end user t
Chapterselect the4 -entireObjectmonth)-Oriented. Programming with C#
Chapter 5 - Exceptions and Object Lifetime
ChapterWorking6 - withInterfacestheandAdRotatorCollections
Chapter 7 - Callback Interfaces, Delegates, and Events
Although classic ASP also provided an AdRotator control, the ASP.NET variation has been substantially
Chapter 8 - Advanced C# Type Construction Techniques
upgraded. The role of this widget is to randomly display a given advertisement at some position in the browser.
When you place a server-side AdRotator widget on your design time template, the display is a simple
Chapter 9 - Understanding .NET Assemblies
placeholder. Functionally, this control cannot do its magic until you set the AdvertisementFile property to point t
Chapter 10 - Processes, AppDomains, Contexts, and Threads the XML file that describes each ad.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartTheFourformat- Leveragingof the advertisementthe .NET Librariesfile is quite simple. For each ad you wish to show, create a unique <Ad> Chapterelement12. At- Objectminimum,Serializationeach <Ad>andelementthe .NETspecifiesRemotingtheLayerimage to display (ImageUrl), the URL to navigate to if t
Chapterimage is13selected- Building(TargetUrl),Better Windowmouseover(Introducingtext (AlternateText),Windows Forms)and the weight of the ad (Impressions). For
Chapterexample,14 assume- A BetteryouPaintinghave aFrameworkfile (ads.xml)(GDI+)that defines two possible ads, as shown here:
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
<Advertisements>
Chapter<Ad>17 - Data Access with ADO.NET
Part Five - Web<ImageUrl>SlugBugApplications and XML.Webjpg</ImageUrl>Services
Chapter 18 -<TargetUrl>http://wwwASP.NET Web Pages and Web.ControlsCars.com</TargetUrl>
Chapter 19 -<AlternateText>YourASP.NET Web Applicati ns new Car?</AlternateText>
<Impressions>80</Impressions>
Chapter 20 - XML Web Services
Index </Ad>
<Ad>
List of Figures
List of Tables<ImageUrl>car.gif</ImageUrl> <TargetUrl>http://www.CarSuperSite.com</TargetUrl>
<AlternateText>Like this Car?</AlternateText>
<Impressions>80</Impressions>
</Ad>
</Advertisements>
Once you set the AdvertisementFile property correctly (and ensure that the images and XML file are in the correct virtual directory), one of these two ads is randomly displayed when users navigate to the site, as shown here:
<asp:AdRotator id=myAdRotator runat="server" Width="470"
Height="60" AdvertisementFile="ads.xml">
</asp:AdRotator>
C# and the .NET Platform, Second Edition
When you run this application and post back to the page, you will randomly be presented with one of two *.jpg
by Andrew Troelsen ISBN:1590590554
files. Be aware that the Height and Width properties of the AdRotator are used to establish the size of your ads.
Apress © 2003 (1200 pages)
this example, each ad is the default 60 × 470 pixels. If your ads are larger (or smaller) than the AdRotator's size you will get skewedThisimagescomprehensive. text starts with a brief overview of the
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Assigning Tab Order and Style Sheets
Before examining how to make use of the ASP.NET validation controls, let's check out the issue of tab order an
Table of Contents
style sheets to an ASP.NET Web control. Like a Windows Forms application, all ASP.NET Web widgets suppor
C# and the .NET Platform, Second Edition
a TabIndex property. What is unique about assigning tab order to ASP.NET Web controls is that tab index 0 is
Introduction
reserved for the browser's URL input field! Therefore, be sure to begin numbering your TabIndex at number 1 t
PartensureOne the- Introduuser caningtabC# aroundtheyour.NETWebPlatformwidgets correctly.
Chapter 1 - The Philosophy of .NET
Next, recall that all ASP.NET Web controls inherit a property named CssStyle. Using this property, you are able
Chapter 2 - Building C# Applications
to easily configure the UI of multiple widgets on your page by assigning an existing cascading style sheet. If you
Part Two - The C# Programming Language
are unfamiliar with this aspect of HTML, simply consider a style sheet as a named set of name/value pairs that
Chapter 3 - C# Language Fundamentals
describe a UI template.
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
For example, assume you have an *.aspx file that defines a style sheet named CustomInputUI:
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
<style>
Chapter 8 - Advanced C# Type Construction Techniques
.CustomInputUI { FONT: 10pt verdana; COLOR: green }
Part Three - Programming with .NET Assemblies
</style>
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChaptOncerthis11 style- TypesheetReflectis inon,place,Late Binding,you canautomaticallynd Attribute-BasedconfigureProgrammingyour widgets to support a 10-pt, green font
PartusingFourthe- VerdanaL veragingfonttheface.NET. ForLibrariesexample:
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
<asp:TextBox id="myTextBox" runat="server"
Chapter 14 - A Better Painting Framework (GDI+)
CssClass="CustomInputUI">
Chapter</asp:TextBox>15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
SOURCE |
The files for the FunWithControls project are included under the Chapter 18 subdirectory. |
|
Chapter 18 |
- ASP.NET Web Pages and Web Controls |
|
CODE |
|
|
Chapter 19 |
- ASP.NET Web Applications |
Chapter 20 - XML Web Services
IndexThe Mighty DataGrid
List of Figures
The ADO.NET DataGrid is by far and away the most complex of all Web widgets. Up until this point, you have
List of Tables
used the grid in read-only mode; however, the DataGrid type may be configured to support paging, sorting, inplace editing, and so forth. To demonstrate some of the more exotic aspects of this control, fire up VS .NET an create a new Web application (DataGridApp). The only widget you need on the initial *.aspx file is a DataGrid type. Now, within the Page_Load() event handler, fill the grid with the current items in the Inventory table of the Cars database by calling a helper function named UpdateGrid():
public class DataGridPage: System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid myDataGrid; private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
UpdateGrid();
}
}
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
private void UpdateGrid() |
|
{ |
Apress © 2003 (1200 pages) |
|
This comprehensive textDataSet();starts wi h a brief overview of the
DataSet myDS = new
C# language and then quickly moves to key technical and
SqlConnection c = new architectural issues for .NET developers.
SqlConnection("Server=localhost;UID=sa;PWD=;Database=Cars");
c.Open();
SqlCommand s = new SqlCommand("Select * from Inventory", c);
Table of Contents
SqlDataAdapter d = new SqlDataAdapter(s);
C# and the .NET Platform, Second Edition d.Fill(myDS, "Inventory");
Introduction
myDataGrid.DataSource = myDS.Tables["Inventory"];
Part One - Introducing C# and the .NET Platform
myDataGrid.DataBind();
Chapter 1 - The Philosophy of .NET
}
Chapter 2 - Building C# Applications
...
Part Two - The C# Programming Language
}
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
ChapterAt this point,5 - Exceptionsyou shouldandbeObjablecttoLifetimerun your Web app and find a populated DataGrid. Currently, the *.aspx
Chapterdefinition6 of- Interfthe DataGridces andisCollectionsvery simple:
Chapter 7 - Callback Interfaces, Delegates, and Events
Ch<asp:DataGridpter 8 - Advancedid="myDataGrid"C# T pe Construction Techniques
Partstyle="ZThree - Programming-INDEX: 103;withLEFT:.NET Assemblies16px; POSITION: absolute; TOP: 56px"
Chapterrunat="server">9 - Und standing .NET Assemblies
Chapter</asp:DataGrid>10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
In the next several sections, you will enhance the grid in a number of ways. As you would expect, most of these
Chapter 12 - Object Serialization and the .NET Remoting Layer
updates can be automated using VS .NET. If you select your DataGrid widget on the designer, you will notice a link on the Properties window named Property Builder. While this tool will automatically build the correct *.aspx
definitions, I'll concentrate on the raw *.aspx definition just to ensure you understand what makes the grid tick
Chapter 15 - Programming with Windows Forms Controls under the hood.
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Altering Column Names
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
The first aspect of the DataGrid we will examine is the process of assigning custom display names for each of t
Chapter 19 - ASP.NET Web Applications
grid's columns. By default, column display names will map directly to the column names found in the table (whi
Chapter 20 - XML Web Services
may or may not be a problem). When you wish to provide user-friendly names for each column, you will need t
Index
create a <Columns> definition within the scope of the DataGrid itself. The <Columns> definition will contain a s
List of Figures
of <BoundColumn> controls that map data fields to custom header text. Also, you need to ensure that the ListAutoGenerateColumnsof Tabl s attribute of the DataGrid is set to false. Ponder the following:
<asp:DataGrid id="myDataGrid"
style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 56px" runat="server"AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="CarID" HeaderText="Auto Identifier"> </asp:BoundColumn>
<asp:BoundColumn DataField="Make" HeaderText="Make of Auto"> </asp:BoundColumn>
<asp:BoundColumn DataField="Color" HeaderText="Color of Auto"> </asp:BoundColumn>
<asp:BoundColumn DataField="PetName" HeaderText="The Pet Name"> </asp:BoundColumn>
</Columns>
</asp:DataGrid>
C# and the .NET Platform, Second Edition
As you can tell, the DataField attribute of the <BoundColumn>ISBN:1590590554type specifies the name of the column as found by Andrew Troelsen
the database, while the HeaderText attribute holds the friendly name to display in the grid. If you wish, update th
Apress © 2003 (1200 pages)
overall GUI of the grid to suit your liking. In any case, your grid now looks something like Figure 18-24.
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter 6 - Interfaces and Collections
Figure 18-24: A DataGrid with friendly column names
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Note The Property Builder Wizard will generate all of these updates using the Columns tab. For this
Part Three - Programming with .NET Assemblies
example, simply add four BoundColumn types and uncheck the "Create columns automatically at run
Chapter 9 - Understanding .NET Assemblies
time" option.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartEnablingFour - LeveragingPagingthe .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
The next aspect of the DataGrid we will examine is its default paging ability. By default, a DataGrid will display a
Chapter 13 - Building a Better Window (Introducing Windows Forms)
records returned from a SQL query, regardless of how many records are present. Of course, if you have a tabl
Chapter 14 - A Better Painting Framework (GDI+)
that contains 200 records, you typically would not want to have them displayed at the same time. Rather, you
Chapter 15 - Programming with Windows Forms Controls
may wish to configure the DataGrid to only show 10 records at a time, and allow the user to post back to the W
Chapter 16 - The System.IO Namespace
server (via "left" and "right" links or numerical identifiers) to fetch the next (or previous) 10 items.
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
The DataGrid supports this functionality right out of the box. The first step in doing so is to set the PageSize and
Chapter 18 - ASP.NET Web Pages and Web Controls
AllowPaging attributes on the DataGrid type. Once this is done, you will need to add a <PagerStyle> element Chapterwithin the19 scope- ASP.NETof theWebgrid'sApplicationsdefinition. Consider the following example (<Columns> elements have been
Chapterremoved20for- XMLclarity):Web Services
Index
List of Figures
<asp:DataGrid id="myDataGrid" style="Z-INDEX: 103; LEFT: 16px;
List of Tables
POSITION: absolute; TOP: 56px"
runat="server" AutoGenerateColumns="False" Width="424px"
PageSize="5" AllowPaging="True">
...
<PagerStyle Mode="NumericPages" HorizontalAlign="Center"
ForeColor="#330099" BackColor="#FFFFCC">
</PagerStyle>
</asp:DataGrid>
Here, the <PagerStyle> element has been set up to support numerical paging (1, 2, 3) rather than "<" and ">" links.
The final step is to handle the grid's PageIndexChanged event (like any widget, this may be done via VS .NET). This event will fire when the user clicks the link set maintained by the DataGrid. The implementation of this eve handler is as follows:
private void myDataGrid_PageIndexChanged(object source,
C# and the .NET Platform, Second Edition
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
by Andrew Troelsen |
ISBN:1590590554 |
{
Apress © 2003 (1200 pages)
// Set the grid's current page index to the new page index.
This comprehensive text starts with a brief overview of the
myDataGrid.CurrentPageIndex = e.NewPageIndex;
C# language and then quickly moves to key technical and
UpdateGrid();
architectural issues for .NET developers.
}
Table of Contents
Notice how the incoming DataGridPageChangedEventArgs type supplies the NewPageIndex property. As you
C# and the .NET Platform, Second Edition
would expect, this will be used to compute the next batch of records to display. Once you assign this value to th
Introduction
grid's CurrentPageIndex property, you will need to repopulate your grid via your helper UpdateGrid() function.
Part One - Introducing C# and the .NET Platform
Figure 18-25 shows the new GUI. |
|
Chapter 1 - The Philosophy of .NET |
|
Chapter 2 - Building C# Applications |
|
Part |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Part |
|
Chapter |
|
Chapter |
Threads |
Chapter |
-Based Programming |
Part |
|
Chapter |
Layer |
Chapter |
Windows Forms) |
Chapter |
|
Chapter 15 - Programming with Windows Forms Controls
Figure 18-25: A DataGrid default paging support
Chapter 16 - The System.IO Namespace
As you will see in the next chapter, ASP.NET provides numerous ways to cache objects (such as DataSets) in
Chapter 17 - Data Access with ADO.NET
memory. Thus, if you were to store the DataSet in a session variable, you would not need to directly query the
Part Five - Web Applications and XML Web Services
database within the PageIndexChanged event handler, but simply assign the cached object to the DataGrid's
Chapter 18 - ASP.NET Web Pages and Web Controls
DataSource property.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Note The Property Builder Wizard will generate all of these updates using the Paging tab.
Index
List of Figures
Enabling In-Place Editing
List of Tables
The final feature of the DataGrid we will examine here is the ability for the grid to support in-place activation. Th is a very helpful feature, given that it allows the Web user to select a row for editing and push the changes back to the Web server for processing.
The first task is to add a new member to the <Columns> element named <EditCommandColumn>. This single element will be used to render back the necessary Edit, Cancel, and Update links to be displayed in the browse
<Columns>
...
<asp:EditCommandColumn
ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit">
</asp:EditCommandColumn>
</Columns>
Notice that this elemeC# antdhasthebeen.NETconfiguredPlatform, Secondto displayEditionthree hyperlinks that allow the user to activate a row for editing and submitbyorAndrewcancelTrothelsenchanges. In addition to updatingISBN:1590590554the <Columns> element, let's update the DataGrid's definitionApressof the© 2003CarID(1200columnpages) to be read-only (to prevent the user from changing the value of this primary key):
<Columns>
...
<asp:BoundColumn DataField="CarID" ReadOnly="True"
Table of Contents
HeaderText="Auto Identifier">
C# and the .NET Platform, Second Edition
</asp:BoundColumn>
Introduction
</Columns>
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChapterThe final2 *-.asxpBuildingmodificationC# Applicationsyou will typically want to make is to set the DataGrid.DataKeyField property to the
PartvalueTwoof-theThetable'sC# Programmingprimary keyLanguage. As you will see, this can be helpful when handling the updates on the Web
Chaptserver,3given- C#thatLanguagethe gridFundamhas foreknowledgentals of the correct primary key:
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
<asp:DataGrid id="myDataGrid" ...
ChDataKeyField="CarID">pter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
With this GUI prep work complete, the next task is to handle three server-side events for each possibility
Part Three - Programming with .NET Assemblies
(CancelCommand, EditCommand, and UpdateCommand).
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
The implementation of the EditCommand handler will simply inform the DataGrid which row is currently being
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
edited by assigning it the selected item via the incoming DataGridCommandEventArg type:
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
private void myDataGrid_EditCommand(object source,
Chapter 13 - Building a Better Window (Introducing Windows Forms)
System.Web.UI.WebControls.DataGridCommandEventArgs e)
Chapter 14 - A Better Painting Framework (GDI+)
{
Chapter 15 - Programming with Windows Forms Controls
// Tell grid which row is active.
Chapter 16 - The System.IO Namespace myDataGrid.EditItemIndex = e.Item.ItemIndex;
Chapter 17 - Data Access with ADO.NET
UpdateGrid();
Part Five - Web Applications and XML Web Services
}
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
The code within the CancelCommand event handler is also equally as simple. Here, you will inform the grid to
Chapter 20 - XML W b Services
exit the edit mode by assigning the EditItemIndex property to -1 (alas, a "magic number" is used here. Sadly, w
Index
don't have a strongly typed enumeration).
List of Figures
List of Tables
private void myDataGrid_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
// Disable edit mode.
myDataGrid.EditItemIndex = -1;
UpdateGrid();
}
The real work takes place within the implementation of the UpdateCommand event handler. When the user clicks the Update link, the incoming DataGridCommandEventArgs parameter will contain the values within eac cell of the row currently under edit mode. Your task is to access the internal controls collection to obtain these values, format a SQL update statement, and submit the changes. In the code that follows, notice that you are accessing each cell in order, thus cell 0 is the CarID (which you obtain via the DataKeys collection), cell 1 is the Make, and so on. Before exiting this event handler, be sure to tell the DataGrid to exit out of edit mode using the
magic number -1:
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
private void myDataGrid_UpdateCommand(object source,
Apress © 2003 (1200 pages)
System.Web.UI.WebControls.DataGridCommandEventArgs e)
This comprehensive text starts with a brief overview of the
{
C# language and then quickly moves to key technical and
// Get new info from the cells of the row being edited. architectural issues for .NET developers.
int theCarID;
TextBox newMake, newColor, newPetName;
TabletheCarIDof ontents= (int)myDataGrid.DataKeys[e.Item.ItemIndex];
newMake = (TextBox)e.Item.Cells[1].Controls[0];
C# and the .NET Platform, Second Edition
newColor = (TextBox)e.Item.Cells[2].Controls[0];
Introduction
newPetName = (TextBox)e.Item.Cells[3].Controls[0];
Part One - Introducing C# and the .NET Platform
// Build a SQL string based on cell info.
Chapter 1 - The Philosophy of .NET
string sqlUpdate = string.Format(
Chapter 2 - Building C# Applications
"Update Inventory Set Make='{0}', Color='{1}', PetName='{2}' Where CarID='{3}'
Part Two - The C# Programming Language
newMake.Text.Trim(), newColor.Text.Trim(),
Chapter 3 - C# Language Fundamentals
newPetName.Text.Trim(), theCarID);
Chapter 4 - Object-Oriented Programming with C#
// Submit SQL to DB using a command object.
Chapter 5 - Exceptions and Object Lifetime
SqlConnection c = new
Chapter 6 - Interfaces and Collections
SqlConnection("Server=localhost;UID=sa;PWD=;Database=Cars");
Chapter 7 - Callback Interfaces, Delegates, and Events c.Open();
Chapter 8 - Advanced C# Type Construction Techniques
SqlCommand s = new SqlCommand(sqlUpdate,c);
Part Three - Programming with .NET Assemblies
s.ExecuteNonQuery();
Chapter 9 - Understanding .NET Assemblies
c.Close();
Chapter 10 - Processes, AppDomains, Contexts, and Threads
// Exit out of edit mode.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming myDataGrid.EditItemIndex = -1;
PartUpdateGrid();Four - Leveraging the .NET Libraries
Chapter} 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
That's it! At this point, if you run your application, you will find that you are able to select a row for editing, and
Chapter 15 - Programming with Windows Forms Controls
then commit or cancel the changes (Figure 18-26).
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part
Chapter
Chapter
Chapter
Index
List of
List of
Figure 18-26: An editable DataGrid
As you would guess, the ASP.NET DataGrid has support for other bells and whistles such as deleting a row, programmatically add a new row, sorting ability, and whatnot. At this point, however, you should have a solid handle on some of the key features of this Web control.
SOURCE |
The files for the DataGridApp project are included under the Chapter 18 subdirectory. |
CODE
Data-Centric Controls and Data Binding |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
As you have seen, the DataGrid control provides the DataSource and DataBind() members to allow you to rend
Apress © 2003 (1200 pages)
the contents of a given ADO.NET DataTable or DataReader type. This is obviously a great boon to the enterpri
This comprehensive text starts with a brief overview of the
developer. However, WebForm controls (as well as Windows Forms controls) also allow you to bind other
C# language and then quickly moves to key technical and
sources of data to a given widget.
architectural issues for .NET developers.
For example, assume that you have a well-known set of values represented by a simple string array. Using the
same technique as for binding to DataGrid types, you can attach an array to a GUI type. For example, if you
Table of Contents
place an ASP.NET ListBox control (with the ID of petNameList) on your *.aspx page, you can update the
C# and the .NET Platform, Second Edition
Page_Load() event handler as shown here:
Introduction
Part One - Introducing C# and the .NET Platform
protected void Page_Load(object sender, EventArgs e)
Chapter 1 - The Philosophy of .NET
{
Chapter 2 - Building C# Applications
if (!IsPostBack)
Part Two - The C# Programming Language
Chapter {3 |
- C# Language Fundamentals |
Chapter 4 |
- Object// Create-Oriented anProgrammingarray ofwithdataC# to bind to the list box. |
Chapter 5 |
string[] carPetNames = |
- Exceptions and Object Lifetime |
|
Chapter 6 |
{ |
- Interfaces and Collections |
|
|
"Viper", "Hank", "Ottis", "Alphonzo", "Cage", "TB" |
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
}; |
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
petNameList.DataSource = carPetNames; |
Part Three - Programming with .NET Assemblies |
|
|
petNameList.DataBind(); |
Chapter 9 |
- Understanding .NET Assemblies |
} |
|
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
} |
|
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
Part Four - Leveraging the .NET Libraries
Recall that all .NET arrays map to the System.Array type. Also recall that System.Array implements the
Chapter 12 - Object Serialization and the .NET Remoting Layer
IEnumerable interface. The fact is that any type that implements IEnumerable can be bound to a GUI widget.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Therefore, if you update your simple string array to an instance of the ArrayList type, the output is identical, as
Chapter 14 - A Better Painting Framework (GDI+)
shown here:
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
protected void Page_Load(object sender, EventArgs e)
Chapter 17 - Data Access with ADO.NET
{
Part Five - Web Applications and XML Web Services
if (!IsPostBack)
Chapter 18 - ASP.NET Web Pages and Web Controls
{
Chapter 19 - ASP.NET Web Applications
// Now use an array list.
Chapter 20 - XML Web Services
Index |
ArrayList carPetNames = new ArrayList(); |
List of Figures |
carPetNames.Add("Viper"); |
List of Tables |
carPetNames.Add("Ottis"); |
carPetNames.Add("Alphonzo"); |
|
|
carPetNames.Add("Cage"); |
|
carPetNames.Add("TB"); |
|
petNameList.DataSource = carPetNames; |
} |
petNameList.DataBind(); |
|
|
} |
|
The Role ofC#theandValidationthe .NET Platform,ControlsSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
The final group of WebForm controls we will examine are termed validation controls. Unlike the other
Apress © 2003 (1200 pages)
WebForm controls we have been examining, validator controls are not used to emit HTML, but client-side
This comprehensive text starts with a brief overview of the
JavaScript for theC#purposelanguageof formand thenvalidationquickly. Asmovesillustratedto keyattecthenicalbeginninga d of this chapter, client-side form validation is quitearchitecturaluseful in thatissuesyou canfor .ensureNET d velopersthat various. constraints are in place before posting back to the Web server, thereby avoiding expensive round-trips. Table 18-14 gives a rundown of the ASP.NET validation controls.
Table of Contents
C# and the .NET Platform, Second Edition |
||||||||
|
Table 18-14: The ASP.NET Validation Controls |
|||||||
|
|
Introduction |
|
|
|
|
|
|
PartWebFormOne - IntroducingValidationC# and the .NETMeaningPlatform in Life |
|
|
||||||
|
ChapterControl1 - The Philosophy of .NET |
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
Chapter 2 |
- Building C# Applications |
|
|
Validates that the value of an input control is equal to a given |
|
|
|
|
CompareValidator |
|
|
|
|
||
Part Two - The C# Programming Language |
|
|
||||||
|
|
|
|
|
|
value of another input control. |
|
|
|
Chapter 3 |
- C# Language Fundamentals |
|
|
||||
|
|
|
||||||
|
|
CustomValidator |
Allows you to build a custom validation function that validates a |
|
|
|||
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
|
||||
|
|
|
|
|
|
given control. |
|
|
|
Chapter 5 |
- Exceptions and Object |
|
Lifetime |
|
|
||
|
|
|
||||||
|
|
Chapter 6 |
- Interfaces and Collections |
|
|
|
|
|
|
|
RangeValidator |
|
|
Determines that a given value is in a predetermined range. |
|
|
|
|
|
|
|
|
|
|
||
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
|||
|
|
RegularExpressionValidator |
Checks if the value of the associated input control matches the |
|
|
|||
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
||||
|
|
|
|
|
|
pattern of a regular expression. |
|
|
Part Three - Programming with .NET |
Assemblies |
|
|
|||||
|
|
|
|
|
|
|
||
|
|
Chapter 9 |
- Un erstanding .NET Assemblies |
|
|
|||
|
|
RequiredFieldValidator |
Ensures that a given input control contains a value (and is thus |
|
|
|||
|
Chapter 10 |
- Processes, AppDomains, C ntexts, and Threads |
|
|
||||
|
|
|
|
|
|
not empty). |
|
|
|
|
|
|
|
||||
|
|
Chapter 11 |
- Type Reflection, Late |
|
Binding, and Attribute-Based Programming |
|
|
|
|
|
ValidationSummary |
|
|
Displays a summary of all validation errors of a page in a list, |
|
|
|
Part Four - Leveraging the .NET Libraries |
|
|
||||||
Chapter 12 |
|
|
|
bulleted list, or single paragraph format. The errors can be |
|
|
||
- Object Serialization and the .NET Remoting Layer |
|
|
||||||
|
|
|
|
|
|
displayed inline and/or in a pop-up message box. |
|
|
|
|
Chapter 13 |
- Building a Better Window |
(Introducing Windows Forms) |
|
|
||
Chapter 14 |
- A Better Painting Framework (GDI+) |
|||||||
Chapter 15 |
- Programming with Windows Forms Controls |
All of the validator controls ultimately derive from a common base class named
ChapSystemr 16.Web- The.UI.SystemWebControls.IO Namespace.BaseValidator, and therefore have a set of common features. Table 18-15
Chapterdocuments17 - theDatakeyAccessmemberswith ADO. .NET
Part Five - Web Applications and XML Web Services
ChTablept r 18-15:- ASPCommon.NET WebPropertiesPag s and Webof theControlsASP.NET Validators
|
|
|
|
|
|
|
|
Chapter 19 - ASP.NET Web Applications |
|
Meaning in Life |
|
|
|
Member of the |
|
|
|
|
|
Chapter 20 - XML Web Services |
|
|
|
|
|
BaseValidator Type |
|
|
|
|
Index |
|
|
|
|
|
|
|
|
||
ListControlToValidatef Figures |
|
Gets or sets the input control to validate |
|
||
|
|
|
|
|
|
List of Tables |
|
Gets or sets the display behavior of the error message in |
|
||
|
|
Display |
|
|
|
|
|
|
|
a validation control |
|
|
|
|
|
|
|
|
|
EnableClientScript |
|
Gets or sets a value indicating whether client-side |
|
|
|
|
|
validation is enabled |
|
|
|
|
|
|
|
|
|
ErrorMessage |
|
Gets or sets the text for the error message |
|
|
|
|
|
|
|
|
|
ForeColor |
|
Gets or sets the color of the message displayed when |
|
|
|
|
|
validation fails |
|
|
|
|
|
|
|
Working with the ASP.NET Validators
To illustrate the basics of working with validation controls, let's create a new C# Web Application project workspace named ValidatorCtrls. To begin, place a single Button and four TextBox types (with four corresponding and descriptive Labels) onto your page. Next, place a RequiredFieldValidator,
RangeValidator, RegularExpressionValidator, and CompareValidator type adjacent to each respective
C# and the .NET Platform, Second Edition field (Figure 18-27).
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
overview of the
key technical and
Table
C# and
Part
Chapter
Chapter
Part
ChapterFigure3 - 18C#-27:LanguageThe itemsFundamentto be validatedls
Chapter 4 - Object-Oriented Programming with C#
Configuring the RequiredFieldValidator is very straightforward. Simply set the ErrorMessage and
Chapter 5 - Exceptions and Object Lifetime
ControlToValidate properties accordingly using the VS .NET Properties window. The resulting *.aspx
Chapter 6 - Interfaces and Collections
definition is as follows:
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
<asp:RequiredFieldValidator id="RequiredFieldValidator1"
Part Three - Programming with .NET Assemblies
style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 64px"
Chapter 9 - Understanding .NET Assemblies
runat="server"ErrorMessage="You must enter something!"
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ControlToValidate="txtReqField">
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
</asp:RequiredFieldValidator>
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
One nice thing about the RequiredFieldValidator is that it supports an InitialValue property. You can use
Chapter 14 - A Better Painting Framework (GDI+)
this property to ensure that the user enters any value other than the initial value in the related TextBox. For
Chapter 15 - Programming with Windows Forms Controls
example, when the user first posts to a page, you may wish to configure a TextBox to have the string
Chapter 16 - The System.IO Namespace
"ENTER INFO". Now, if you did not set the InitialValue property of the RequiredFieldValidator, the runtime Chapterwould assume17 - DatathatAccessthe stringwith ADO"ENTER. T INFO" is valid. Thus, to ensure a required TextBox is valid only
PartwhenFivethe- WebuserApplicationsenters anythingdotherXML WebthanServices"ENTER INFO", configure your widgets as follows:
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
<asp:RequiredFieldValidator id="RequiredFieldValidator1"
Chapter 20 - XML Web Services
style="Z-INDEX: 104; LEFT: 288px; POSITION: absolute; TOP: 64px"
Index
runat="server" ErrorMessage="You must enter something!"
ListControlToValidate="txtReqField"of Figures InitialValue="ENTER INFO">
List</asp:RequiredFieldValidator>of Tables
<asp:TextBox id="txtReqField" style="Z-INDEX: 105; LEFT: 116px; POSITION: absolute; TOP: 64px"
runat="server">ENTER INFO</asp:TextBox>
The RegularExpressionValidator can be used when you wish to apply a pattern against the characters entered within a given input field. To ensure that a given TextBox contains a valid U.S. SSN, you could define the widget as follows:
<asp:RegularExpressionValidator id="RegularExpressionValidator1"
style="Z-INDEX: 109; LEFT: 152px; POSITION: absolute; TOP: 246px"
runat="server" ErrorMessage="Not an SSN!"
ControlToValidate="txtMustBeSSN"ValidationExpression="\d{3}-\d{2}\d{4}">
</asp:RegularExpressionValidator>
C# and the .NET Platform, Second Edition
Notice how the RegularExpressionValidator defines a ValidationExpression property. If you have never worked with regular expressions before, all you need to be aware of for this example is that they are used
to match a given string pattern. Here, the expression "\d{3}-\d{2}\d{4}" is capturing a standard U.S. Social
This comprehensive text starts with a brief overview of the
Security number of the form xxx-xx-xxxx. This particular regular expression is fairly self-explanatory;
however, assume you wish to test for a valid Japanese phone number. The correct expression now architectural issues for .NET developers.
becomes much more complex: "(0\d{1,4}-|\(0\d{1,4}\) ?)?\d{1,4}-\d{4}". The good news is that when you select the ValidationExpression property using the Properties window of VS .NET, you can pick from a
predefined set of possible regular expressions (Figure 18-28).
Table of Contents
C# and the .NET Platform, Second Edition
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 18-28: Creating a regular expression via VS .NET
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourNote- LeveragingIf you are reallythe .NETinto Librariesregular expressions, you will be happy to know that the .NET platform Chapter 12 supplies- Object Serializationan entire namespaceand the .NET(SystemRemoting.TextLayer.RegularExpressions) devoted to the programmatic
manipulation of such patterns.
Chapter 13 - Building Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
In addition to a MinimumValue and MaximumValue property, RangeValidators have a property named
Chapter 15 - Programming with Windows Forms Controls
Type. Because you are interested in testing the user-supplied input against a range of whole numbers, you
Chapter 16 - The System.IO Namespace
need to specify "Integer" (which is not the default!).
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
<asp:RangeValidator id="RangeValidator1"
Chapter 18 - ASP.NET Web Pages and Web Controls
style="Z-INDEX: 112; LEFT: 288px; POSITION: absolute; TOP: 136px"
Chapter 19 - ASP.NET Web Applications
runat="server" ErrorMessage="Must be between 3 and 8!"
Chapter 20 - XML Web Services
ControlToValidate="txtNumberRange"MaximumValue="8"
Index
MinimumValue="3" Type="Integer">
List of Figures
</asp:RangeValidator>
List of Tables
The RangeValidator can also be used to test if a given value is between a currency value, date, floating point number, or string data (the default setting).
Finally, notice that the CompareValidator supports an Operator property:
<asp:CompareValidator id="CompareValidator1"
style="Z-INDEX: 115; LEFT: 288px; POSITION: absolute; TOP: 176px"
runat="server" ErrorMessage="Must be greater than 4!"
ControlToValidate="txtGreaterThanFour" Type="Integer"
ValueToCompare="4" Operator="GreaterThan">
</asp:CompareValidator>
Given that the role of this validator is to compare the value in the text box against another value using a
binary operator, it should be no surprise that the Operator property may be set to values such as
C# and the .NET Platform, Second Edition
LessThan, GreaterThan, Equal, NotEqual, and so forth. Also, note that the ValueToCompare is used to
by Andrew Troelsen ISBN:1590590554 establish a value to compare against.
Apress © 2003 (1200 pages)
Note The CompareValidatorThis comprehensivecantextalsostartsbe configuredwith a brieftooverviewcompareofathevalue within another WebForm controlC#(ratherlanguagethan andhardthen-codedquicklyvalue)movesusingto keythetechControlToValidateical and property.
architectural issues for .NET developers.
To finish up the code for this page, handle the Click event for the Button type and inform the user s/he has succeeded in the validation logic:
Table of Contents
C# and the .NET Platform, Second Edition
private void btnPostBack_Click(object sender, System.EventArgs e)
Introduction
{
Part One - Introducing C# and the .NET Platform
Response.Write("You passed validataion!");
Chapter 1 - The Philosophy of .NET
Response.End();
Chapter 2 - Building C# Applications
}
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Now, navigate to this page using your browser of choice. At this point, you should not see any noticeable
Chapter 4 - Object-Oriented Programming with C#
changes. However, when you attempt to click the Submit button after entering bogus data, your error
Chapter 5 - Exceptions and Object Lifetime
message is suddenly visible, as shown in Figure 18-29.
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter
Part
Chapter |
|
Chapter |
|
Chapter |
Based Programming |
Part |
|
Chapter |
Layer |
Chapter |
Forms) |
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Part |
|
Chapter |
|
Chapter 19 - ASP.NET Web Applications |
|
Figure 18-29: Bad data . . . |
|
Chapter 20 - XML Web Services |
|
Index
Once you enter valid data, the error messages are removed and postback occurs.
List of Figures
List of Tables
If you look at the HTML rendered by the browser, you see that the validator controls generate a client-side JavaScript function that makes use of a specific library of JavaScript functions (contained in the WebUIValidation.js file) that is automatically downloaded to the user's machine. Once the validation has occurred, the form data is posted back to the server, where the ASP.NET runtime will perform the same validation tests on the Web server (just to ensure that no along-the-wire tampering has taken place).
On a related note, if the HTTP request was sent by a browser that does not support client-side JavaScript, all validation will occur on the server. In this way, you can program against the validator controls without being concerned with the target browser; the returned HTML page redirects the error processing back to the Web server.
Note It is permissible to assign more than one validator to a single widget. For example, if you wish to ensure that the user enters a mandatory phone number, you can associate a RequiredFieldValidator and RegularExpressionValidator to the same input field.
Performing Custom Validation
Although the ASP.NET validators we have just examined will take care of most (if not all) of your form-
C# and the .NET Platform, Second Edition
level validation, there may be a time in which you want to craft some custom validation logic (either server- |
|
by Andrew Troelsen |
ISBN:1590590554 |
side or client-side). Sometimes, for example, validation requires you to read from a remote data source,
Apress © 2003 (1200 pages)
and therefore a postback to the Web server is mandatory. When you have a validation need that will
This comprehensive text starts with a brief overview of the
always entail a round trip, you could choose to manually build a postback handler; however, the
C# language and then quickly moves to key technical and
CustomValidator can simplify matters.
architectural issues for .NET developers.
By way of illustration, assume you have a new TextBox field that can only be validated on the Web server
(Figure 18-30).
Table of Contents
C# and the .NET Platform, Second Edition
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 18-30: Custom server-side validation GUI prep
Chapter 8 - Advanced C# Type Construction Techniques
PartHereThreeis the- Programmingcomplete *.aspxwithdeclaration:.NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Ch<asp:CustomValidatorpter 10 - Processes, AppDomains, Contexts, and Threads
id="CustomValidator1"
Chapterstyle="Z11 --TypeINDEX:Reflection,119;LateLEFT:Binding,400px;and AttributePOSITION:-Based Programmingabsolute; TOP: 232px"
Partrunat="server"Four - L veragingErrorMessage="Serverthe .NET Libr ri said No-Dice"
ChapterControlToValidate="txtServerSideVal">12 - Object Serializa ion and the .NET Remoting Layer
Chapter</asp:CustomValidator>13 - Building Bet er Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
When the user attempts to post back, the runtime will automatically trigger a server-side event handler for the CustomValidator.ServerValidate event. Given this, the next step to establish custom server-side validation is to handle this event in the System.Web.UI.Page-derived type using the VS .NET Properties
window. For this example, you will simply generate a random number to see if the validation succeeds.
Chapter 18 - ASP.NET Web Pages and Web Controls
Notice that this method will set the IsValid property of the incoming ServerValidateEventArgs type
Chapter 19 - ASP.NET Web Applications accordingly:
Chapter 20 - XML Web Services
Index
public class ValidatePage : System.Web.UI.Page
List of Figures
{
List of Tables
...
private void InitializeComponent()
{
this.CustomValidator1.ServerValidate +=
new System.Web.UI.WebControls.ServerValidateEventHandler (this.CustomValidator1_ServerValidate);
...
}
private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
Random r = new Random(); int i = r.Next(50);
if(i > 45)
args.IsValid = true;
else
args.IsValid = false;
|
} |
C# and the .NET Platform, Second Edition |
|
|
... |
by Andrew Troelsen |
ISBN:1590590554 |
||
|
||||
|
|
|
}Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
If you run this example, you will now find that your server-side event handler will run automatically. If the randomly generated number is greater than 45, validation succeeds!
Table of Contents
In addition to building a server-side validation routine, the CustomValidator type may also be configured to C#functionand theon.NETthePlatform,client sideSec. Forndexample,Edition assume that you have a widget that will be validated based on a
Inumbertroductiofn complex conditions and interactions with the browser's DOM. In this case, you can create a
PartcustomOne -JavaScriptIntroducingorC#VBScriptand thefunction.NET Platformthat will be called automatically on the client. The key is to set the
ChapterClientValidationFunction1 - The Philos phypropertyf .NETthat points to the name of the script code emitted to the browser. For
Chapterexample:2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
<HTML>
Chapter<HEAD>4 - Object-Oriented Programming with C#
Chapter<title>Fun5 - Exceptionswith Validators</title>and Object Lifetime
Chapter<script6 -languageInterfaces and= vbscript>Colle tions
Sub SomeVBScriptFunction(s, e)
Chapter 7 - Callback Interfaces, Delegates, and Events
' Write the client-side VBScript code.
Chapter 8 - Advanced C# Type Construction Techniques
' Set the IsValid property of 'e'
Part Three - Programming with .NET Assemblies
End Sub
Chapter 9 - Understanding .NET Assemblies
</script>
Chapter 10 - Processes, AppDomains, Contexts, and Threads
...
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
<asp:CustomValidator id="CustomValidator1"
Part Four - Leveraging the .NET Libraries
runat="server" ErrorMessage="CustomValidator"
Chapter 12 - Object Serialization and the .NET Remoting Layer
ClientValidationFunction="SomeVBScriptFunction">
Chapter 13 - Building a Better Window (Introducing Windows Forms)
</asp:CustomValidator>
Chapter 14 - A Better Painting Framework (GDI+)
</HTML>
Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
ChapterNotice 17how- theDatasignatureAccess withof theADOclient.NET-side VBScript function matches the pattern of the related delegate,
PartusingFivethe- WebtypelessApplicationsworld of andVBScriptXML Web. Nevertheless,Servic your client-side validation function will still need to set
Chapterthe IsValid18 -propertyASP.NETofWebthePagesincomiangd secondWeb Contargumentols to inform the runtime if validation succeeded.
Chapter 19 - ASP.NET Web Applications
ChaptCreatingr 20 - XMLValidationWeb Services Summaries
Index
ListTheoffinalFiguresvalidation-centric topic we will examine here is the use of the ValidationSummary widget. ListCurrently,of Tableseach of your validators displays its error message at the exact place in which it was positioned at design time. In many cases, this may be exactly what you are looking for. However, on a complex form with numerous input widgets, you may not want to have random blobs of red text pop up. Using the ValidationSummary type, you can instruct all of your validation types to display their error messages at a specific location on the page.
The first step is to simply place a ValidationSummary on your *.aspx file. You may optionally set the HeaderText property of this type as well as the DisplayMode, which by default will list all error messages as a bulleted list.
<asp:ValidationSummary id="ValidationSummary1"
style="Z-INDEX: 123; LEFT: 152px; POSITION: absolute; TOP: 320px"
runat="server" Width="353px"
HeaderText="Here are the stupid things you have done.">
</asp:ValidationSummary>
Next, you need to set the Display property to None for each of the individual validators (e.g.,
C# and the .NET Platform, Second Edition
RequiredFieldValidator, RangeValidator, etc.) on the page. This will ensure that you do not see duplicate
by Andrew Troelsen ISBN:1590590554
error messages for a given validation failure (one in the summary pane and another at the validator's
Apress © 2003 (1200 pages)
location).
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Once you do so, you will find the output shown in Figure 18-31. architectural issues for .NET developers.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Figure 18-31: Using a validation summary
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Last but not least, if you would rather have the error messages displayed using a client-side MessageBox,
Chapter 10 - Processes, AppDomains, Contexts, and Threads
set the ShowMessageBox property to true and the ShowSummary property to false.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourSOURCE- LeveragingThet .ValidatorCtrlsNET Libraries project is included under the Chapter 18 subdirectory.
ChapterCODE12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .RoleNET Platform,of ASPSecond.NETEditionHTML Controls
by Andrew Troelsen |
ISBN:1590590554 |
In addition to the GUI widgets found within System.Web.UI.WebControls, ASP.NET also defines another
Apress © 2003 (1200 pages)
GUI-centric namespace: System.Web.UI.HtmlControls. Like the official Web controls, the members of the
This comprehensive text starts with a brief overview of the
HtmlControls namespaceC# languageareandorganizedthen quicklywithinmovesa classtohierarchyk y technical(Figureand 18-32). architectural issues for .NET developers.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter 9 - Understanding .NET Assemblies
Figure 18-32: The System.Web.UI.HtmlControls hierarchy
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Given the fact that you are able to build complete ASP.NET Web applications using nothing but the official
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
WebForm controls, you may wonder exactly why you have been given two widget namespaces. The main
Part Four - Leveraging the .NET Libraries
reason has to do with the process of migrating legacy *.html files to the world of ASP.NET. Simply put,
Chapter 12 - Object Serialization and the .NET Remoting Layer
ASP.NET allows you to treat a simple HTML widget (which could be generated via toolkits such as
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ColdFusion or FrontPage) as a full-blown object, capable of server-side event handling and programmatic
Chapter 14 - A Better Painting Framework (GDI+)
manipulation.
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
For example, create a new ASP.NET Web application and build a GUI using the HTML Toolbox tab (not the
Chapter 17 - Data Access with ADO.NET
WebControls tab!) that consists of an HTML Button, HTML Label, and HTML TextBox. The initial *.aspx
Part Five - Web Applications and XML Web Services
definition looks like the following (notice the lack of runat="server"):
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
<INPUT id="btnHtmlButton" style="Z-INDEX: 101; LEFT: 24px;
Chapter 20 - XML Web Services
POSITION: absolute; TOP: 56px"
Index
type="button" value="Set The Label with value in TextBox">
List of Figures
<DIV id="lblHtmlLabel" style="DISPLAY: inline; Z-INDEX: 102;
List of Tables
LEFT: 200px; WIDTH: 70px; POSITION: absolute; TOP: 24px; HEIGHT: 15px" ms_positioning="FlowLayout">Label</DIV>
<INPUT id="txtHtmlTextBox" style="Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 24px" type="text">
If you were to now look in the associated code behind file, you would not find member variables that represent these widgets, given that they have not been configured as server-side controls. To do so, select all of the widgets on the ASP.NET designer, right-click,and select Run as Server Control. Once you do, the *.aspx file will be updated as follows:
<INPUT id="btnHtmlButton" style="Z-INDEX: 101; LEFT: 24px;
POSITION: absolute; TOP: 56px"
type="button" value="Set The Label with value in TextBox" runat="server">
<DIV id="lblHtmlLabel" style="DISPLAY: inline; Z-INDEX: 102;
C# and the .NET Platform, Second Edition
LEFT: 200px; WIDTH: 70px; POSITION:
by Andrew Troelsen |
ISBN:1590590554 |
absolute; TOP: 24px; HEIGHT: 15px" |
|
Apress © 2003 (1200 pages)
ms_positioning="FlowLayout"runat="server">Label</DIV>
This comprehensive text starts with a brief overview of the
<INPUT id="txtHtmlTextBox" style="Z-INDEX: 103; LEFT: 24px;
C# language and then quickly moves to key technical and
POSITION: absolute; TOP: 24px"
architectural issues for .NET developers. type="text" runat="server">
Table of Contents
More interestingly, the code behind file now has three member variables that represent these server-side
C# and the .NET Platform, Second Edition
widgets:
Introduction
Part One - Introducing C# and the .NET Platform
public class HtmlServerSideWidgetsPage : System.Web.UI.Page
Chapter 1 - The Philosophy of .NET
{
Chapter 2 - Building C# Applications
protected System.Web.UI.HtmlControls.HtmlInputButton btnHtmlButton;
Part Two - The C# Programming Language
protected System.Web.UI.HtmlControls.HtmlGenericControl lblHtmlLabel;
Chapter 3 - C# Language Fundamentals
protected System.Web.UI.HtmlControls.HtmlInputText txtHtmlTextBox;
Chapter 4 - Object-Oriented Programming with C#
...
Chapter 5 - Exceptions and Object Lifetime
}
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
At this point, your HTML-based widgets may be programmed against as if they were ASP.NET Web
Chapter 8 - Advanced C# Type Construction Techniques
controls. However, be very aware that the names of the properties, methods, and events exposed from the
Part Three - Programming with .NET Assemblies
HtmlControl family will look and feel much more "HTML-like." Thus, if you were to handle the ServerClick
Chapter 9 - Understanding .NET Assemblies
event of the HtmlInputButton type in order to assign the value of the HtmlGenericControl (aka Label) based
Chapter 10 - Processes, AppDomains, Contexts, and Threads
on the value in the HtmlInputText (aka TextBox), you would find the following code:
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
public class HtmlServerSideWidgetsPage : System.Web.UI.Page
Chapter 12 - Object Serialization and the .NET Remoting Layer
{
Chapter 13 - Building a Better Window (Introducing Windows Forms)
protected System.Web.UI.HtmlControls.HtmlInputButton btnHtmlButton;
Chapter 14 - A Better Painting Framework (GDI+)
protected System.Web.UI.HtmlControls.HtmlGenericControl lblHtmlLabel;
Chapter 15 - Programming with Windows Forms Controls
protected System.Web.UI.HtmlControls.HtmlInputText txtHtmlTextBox;
Chapter 16 - The System.IO Namespace
...
Chapter 17 - Data Access with ADO.NET
private void InitializeComponent()
Part Five - Web Applications and XML Web Services
{
Chapter 18 - ASP.NET Web Pages and Web Controls this.btnHtmlButton.ServerClick +=
Chapter 19 - ASP.NET Web Applications
new System.EventHandler(this.btnHtmlButton_ServerClick);
Chapter 20 - XML Web Services
...
Index }
List of Figures
private void btnHtmlButton_ServerClick(object sender, System.EventArgs e)
List of Tables
{
lblHtmlLabel.InnerText = txtHtmlTextBox.Value;
}
}
If you do not have a ton of legacy *.html files, you may never need to interact with the System.Web.UI.HtmlControls namespace. In fact, beyond this example, I will not comment on them further. However, if you are interested, consult online help for additional details.
Note In the same spirit of Windows Forms, understand that it is possible to build custom ASP.NET Web controls. Although I don't have time to examine this topic here, look up "Developing ASP.NET Server Controls" from MSDN for more details.
And Now forC#Somethingand the .NET PlatforCompletely, Second EditionDifferent: GDI+ on the Web
Server
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
Next, I'd like to examine a very intriguing topic that you will most likely make use of when building your
C# language and then quickly moves to key technical and
ASP.NET pages: the use of GDI+ on the Web server. Although it may seem unlikely, ASP.NET Web architectural issues for .NET developers.
development can be greatly enhanced by making use of the types within System.Drawing.dll.
To take things out for a test drive, fire up VS .NET and create a new ASP.NET Web application named
Table of Contents
GdiPlusApp. The initial *.aspx file will allow the user to specify a number of traits regarding the image to be
C# and the .NET Platform, Second Edition
rendered on the Web server and emitted to the requesting browser. Specifically, the user may define a
Introduction
top, left, bottom, and right coordinate position used to render an ellipse within a 200×200 pixel Image
Part One - Introducing C# and the .NET Platform
ASP.NET Web control. Also, the user in question may specify a custom System.String to be rendered in
Chapter 1 - The Philosophy of .NET
the dynamically rendered image, and select a known color used to paint in the background of the Image
Chapter 2 - Building C# Applications
type. To begin, update the UI of your *.aspx file as shown in Figure 18-33.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter |
|
Chapter |
|
Chapter |
Programming |
Part |
|
Chapter |
|
Chapter |
Forms) |
Chapter |
|
Chapter |
|
Chapter 16 - The System.IO Namespace |
|
Figure 18-33: The GDI+ page UI |
|
Chapter 17 - Data Access with ADO.NET |
|
Part Five - Web Applications and XML Web Services |
|
ChapterWithin the18 -PageASP._NETLoad()WebeventPageshandler,WebmakeControlsuse of the static Enum.GetNames() method to fill the ListBox Chapterwith all19members- ASP.NETof theW bKnownColorApplications enumeration. Also, set the Visible property of the Image widget to
false (that way, the user won't see an empty Image placeholder when first logging on):
Chapter 20 - XML Web Services
Index
Listprivateof Figuresvoid Page_Load(object sender, System.EventArgs e)
List{ of Tables
if(!IsPostBack)
{
imgTheImage.Visible = false;
// Load the list box with all colors.
Array theColors = Enum.GetNames(typeof(KnownColor));
lstColors.DataSource = theColors;
lstColors.DataBind();
}
}
All of the true GDI+ action takes place in the Button Click event handler. Note in the code that follows that you must specify a C# "using" directive for the System.Drawing.Imaging namespace, given that this defines the ImageFormat enumeration. Ponder the following:
private void btnMakeImage_Click(object sender, System.EventArgs e)
{
try
{
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
// Get color from list box to make the SolidBrush.
C# language and then quickly moves to key technical and
KnownColor c = (KnownColor)Enum.Parse(typeof(KnownColor), architectural issues for .NET developers.
lstColors.SelectedValue);
SolidBrush br = new SolidBrush(Color.FromKnownColor(c));
// Make a Bitmap and get Graphics object.
Table of Contents
Bitmap myBitmap = new Bitmap(200, 200);
C# and the .NET Platform, Second Edition
Graphics g = Graphics.FromImage(myBitmap);
Introduction
// Render image based on user prefs.
Part One - Introducing C# and the .NET Platform
g.FillRectangle(br, 0, 0, 200, 200);
Chapter 1 - The Philosophy of .NET g.DrawEllipse(Pens.Blue,
Chapter 2 - Building C# Applications int.Parse(txtLeft.Text),
Part Two - The C# Programming Language
int.Parse(txtTop.Text),
Chapter 3 - C# Language Fundamentals |
||
|
int.Parse(txtRight.Text), |
|
Chapter 4 - Object-Oriented Programming with C# |
||
|
int.Parse(txtBottom.Text)); |
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
|
g.DrawString(txtMessage.Text, |
|
Chapter 6 |
- Interfaces and C |
llections |
|
new Font("Times New Roman", 12, FontStyle.Bold), |
|
Chapter 7 |
- Callback Interfac |
, De egates, and Events |
|
Brushes.Black, 50, 50); |
|
Chapter 8 |
- Advanced// SaveC#imageType Constructionto temp.Techniques |
Part Three - ProgrammingmyBitmapwith.Save(@"C:\Temp\test.NET Assemblies .gif", ImageFormat.Gif);
Chapter 9 - UnderstandingmyBitmap.Dispose();.NET As mblies
g.Dispose();
Chapter 10 - Processes, AppDomains, Contexts, and Threads
imgTheImage.ImageUrl = @"C:\Temp\test.gif";
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
imgTheImage.Visible = true;
Part Four - Leveraging the .NET Libraries
}
Chapter 12 - Object Serialization and the .NET Remoting Layer
catch // User forgot to supply a value...
Chapter 13 - Building a Better Window (Introducing Windows Forms)
{
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Response.End();
Chapter 16 - The System.IO Namespace
}
Chapter 17 - Data Access with ADO.NET
}
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapterAs you19can- see,ASP.NETthis GDI+Web Applilogicationsis identical to the process of rendered GDI+ logic for a Windows Forms
Chaapplicationter 20 -. XMLThe Webkey difference,Services of course, is that you are rendering your drawing logic to an in-memory
IndexBitmap type. Once you have finished rendering the graphical data, save the image to file, assign it to the ListImageUrlof Figuresproperty of the Image widget, and set the Visible property to true. If you run this page, you will be
pleased to see that you can view your dynamically rendered image (Figure 18-34).
List of Tables
ISBN:1590590554
overview of the
technical and
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
ChapterFigure6 - 18Interfaces-34: Servingand Collectionsup dynamic images
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
As you can assume, this is a very powerful technique. For example, imagine a Web page that has the ability to dynamically render a pie chart or bar graph based on a database read. If you are up for the
challenge, try your hand at building a class type that reads the Inventory table of the Cars database (to
Chapter 10 - Processes, AppDomains, Contexts, and Threads
make it more interesting, place this type in a standalone *.dll assembly so other ASP.NET Web
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming applications can access this functionality).
Part Four - Leveraging the .NET Libraries
ChapterSOURCE12 - Object SerializationThe GdiPlusAppand theproject.NET Remotingis includedLayerunder the Chapter 18 subdirectory.
ChapterCODE13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
DebuggingC#andandTracingthe .NET Platform,ASP.NETSecondPagesEdition
by Andrew Troelsen |
ISBN:1590590554 |
Cool! You now have a solid understanding of how ASP.NET Web pages are composed. To close this
Apress © 2003 (1200 pages)
chapter, let's check out the various ways that you can debug your Web apps. If you have worked with
This comprehensive text starts with a brief overview of the
Visual Interdev, youC# understandlanguage andthethenpainquicklyassociatedmoveswithto keydebuggingtechnicalclassicand ASP applications. The good news is that whenarchitecturalyou are buildingissuesASPfor .NETET devWebloprojects,ers. you can use the same debugging techniques as you would with any other sort of Visual Studio .NET project type. Thus, you can set breakpoints in your code behind file (as well as embedded "script" blocks in an *.aspx file), start a debug session (press F5),
Table of Contents
and step through your code.
C# and the .NET Platform, Second Edition
Also, you can enable tracing support for your *.aspx files by specifying the trace attribute in your opening
Introduction
script block, as shown here:
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter<%@ Page2 - Buildinglanguage="c#"C# ApplicationsCodebehind="MyWebForm.aspx.cs"
PartAutoEventWireup="false"Two - The C# Programming LanguageInherits="MyNamespace.MyWebForm" trace = "true" %>
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
When you do so, the returned HTML contains trace information regarding the previous HTTP response.
Chapter 5 - Exceptions and Object Lifetime
To insert your own trace messages into the mix, you can use the Trace type. Any time you wish to log a
Chapter 6 - Interfaces and Collections
custom message (from a script block or C# source code file), simply call the Write() method (Figure 18-
Chapter 7 - Callback Interfaces, Delegates, and Events
35):
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
private void MyPageLevelHelperFunction()
Chapter 9 - Understanding .NET Assemblies
{
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Trace.Write("App Category", "Inside helper function...");
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
}
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Index
List of
List of
Figure 18-35: Logging custom trace messages
Summary C# and the .NET Platform, Second Edition
by Andrew Troelsen ISBN:1590590554
Building Web applications requires a different frame of mind than is used to assemble traditional desktop
Apress © 2003 (1200 pages)
applications. In this chapter, you began with a quick and painless review of some core Web atoms,
This comprehensive text starts with a brief overview of the
including HTML, HTTP,C# languagethe roleandofthenclientquickly-side scripting,moves to andkey technicalserver-sideandscripts using classic ASP.
architectural issues for .NET developers.
The bulk of this chapter was spent examining the architecture of an ASP.NET page. As you have seen, each *.aspx file in your project has an associated System.Web.UI.Page-derived class. Using this code
Tablebehindof Contentsapproach, ASP.NET allows you to build more reusable and OO-aware systems. Next, this chapter C#examinednd the .theNETusePlatform,of WebSecFormnd Editioncontrols. As you have seen, these GUI widgets are in charge of emitting
HTML tags to the client side. The validation controls are server-side widgets that are responsible for
Introduction
rendering client-side JavaScript to perform form validation, without incurring a round-trip to the server. We
Part One - Introducing C# and the .NET Platform
wrapped up with an example of interacting with the .NET base class libraries, and examined how to
Chapter 1 - The Philosophy of .NET
dynamically render an image using GDI+.
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Chapter 19: ASP.NET Web Applications |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
Theprevious chapter concentrated on the composition and behavior of ASP.NET pages and the Web
This comprehensive text starts with a brief overview of the
controls they contain. This chapter builds on these basics by examining the role of the HttpApplication
C# language and then quickly moves to key technical and
type. As you will see, when you derive a type from HttpApplication, you are able to intercept numerous architectural issues for .NET developers.
events that allow you to treat your Web applications as a cohesive unit, rather than a set of stand-alone *.aspx files.
Table of Contents
In addition to investigating the HttpApplication type, this chapter also addresses the all-important topic of
C# and the .NET Platform, Second Edition
state management. Here you will learn the role of view state, session, and application-level variables, as
Introduction
well as a new state-centric entity provided by ASP.NET termed the application cache. Once you have a
Part One - Introducing C# and the .NET Platform
solid understanding of the state management techniques offered by the .NET platform, the chapter wraps
Chapter 1 - The Philosophy of .NET
up with a discussion of the role of the web.config file, and you come to learn various configuration-centric
Chapter 2 - Building C# Applications
techniques.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
The Issue of State
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
At the beginning of the last chapter, it was pointed out that HTTP is a stateless wire protocol. This very fact Chaptmakesr 6Web- Interfacesdevelopmentand Collectionsextremely different from the process of building a stand-alone desktop
Chaapplication,ter 7 - CallbackWindowsIntService,rfa s,orDelegates,console-basedand EventsUI. For example, when you are building a Windows
ChapterForms 8application,- Adva cedyouC#canTyperestConassuredtructionthatTechniquany members variables defined in the main Form will exist in
PartmemoryThreeuntil- Programmingthe user explicitlyw th .NETshutsA sembliesdown the executable:
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads public class MyMainWindow : Form
Chapter{ 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four//- LeveragingState data!the .NET Libraries
Chapter privat12 - ObjectstringSe alizationiAmHereUntilFormShutDown;and the .NET Remoting Layer
Chapter... 13 - Building a Better Window (Introducing Windows Forms)
}
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
In the world of the World Wide Web however, you are not afforded the same luxurious assumption. To prove the point, assume you have a new ASP.NET Web application (named SimpleStateExample) that
has a single *.aspx file. Within the code behind the file, define a page-level string variable named
Chapter 18 - ASP.NET Web Pages and Web Controls userFavoriteCar:
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
public class SimpleStatePage: Page
Index
{
List of Figures
// State data?
List of Tables
private string userFavoriteCar;
...
}
Also, assume that you have constructed the following Web UI as seen in Figure 19-1.
Figure 19-1: The UI for the simple state page
The server-side Click# andeventthehandler.NET Platform,the SetSecondbuttonEditionwill allow the user to assign the string variable using
the value within theby TextBox:Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
private void btnSetFavCar_Click(object sender, System.EventArgs e)
C# language and then quickly moves to key technical and
{
architectural issues for .NET developers.
// Store fav car in member variable.
userFavoriteCar = txtFavCar.Text;
}
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
while the Click event handler for the Get button will display the current value of the member variable within
Part One - Introducing C# and the .NET Platform
the page's Label widget:
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
private void btnShowFavCar_Click(object sender, System.EventArgs e)
Part Two - The C# Programming Language
{
Chapter 3 - C# Language Fundamentals
// Show value of member variable.
Chapter 4 - Object-Oriented Programming with C# lblFavCar.Text = userFavoriteCar;
Chapter 5 - Exceptions and Object Lifetime
}
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Now, if you were building a Windows Forms application, you would be right to assume that once the user
Chapter 8 - Advanced C# Type Construction Techniques
sets the initial value, it would be remembered throughout the life of the desktop application. Sadly, when
Part Three - Programming with .NET Assemblies
you run this Web application, you will find that each time you post back to the Web server, the value of the
Chapter 9 - Understanding .NET Assemblies
userFavoriteCar string variable is set back to the initial empty value, and therefore the Label's text is
Chapter 10 - Processes, AppDomains, Contexts, and Threads
continuously empty.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Again, given that HTTP has no clue how to automatically remember data once the HTTP response has
Chapter 12 - Object Serialization and the .NET Remoting Layer
been sent, it stands to reason that the Page object is destroyed instantly. Therefore, when the client posts
Chapter 13 - Building a Better Window (Introducing Windows Forms)
back to the *.aspx file, a new Page object is constructed that will reset any page-level member variables.
Chapter 14 - A Better Painting Framework (GDI+)
This is clearly a major dilemma. Imagine how painful online shopping would be if every time you posted
Chbackpter 15 - Programming with Windows Forms Controls
to the Web server, any and all information you previously entered (such as the items you wish to Chapterpurchase)16 -wasThediscardedSystem.IO. WhenNamespaceyou wish to remember information regarding the users who are logged
Chapteronto your17 site,- DatayouAccneedss withto makeADO.useNET of various state management techniques.
Part Five - Web Applications and XML Web Services
Note This issue is in no way limited to ASP.NET. Java Servlets, CGI applications, classic ASP, and
Chapter 18 - ASP.NET Web Pages and Web Controls
PHP applications all must contend with the thorny issue of state management.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
To remember the value of the userFavoriteCar string type between post backs, we are required to store
Index
the value of this string type within a session variable. You will examine the exact details of session state in
List of Figures
the pages that follow. For the sake of completion, however, here are the necessary updates for the current
List of Tables
page (note that we are no longer using the private string member variable, therefore feel free to comment out or remove the definition altogether):
private void btnSetFavCar_Click(object sender, System.EventArgs e)
{
//Store fav car in member variable.
//userFavoriteCar = txtFavCar.Text;
Session["UserFavCar"] = txtFavCar.Text;
}
private void btnGetFavCar_Click(object sender, System.EventArgs e)
{
//Show value of member variable.
//lblFavCar.Text = userFavoriteCar;
lblFavCar.Text = (string)Session["UserFavCar"];
}
If you were to nowC#runandthetheapplication,.NET Platform,the valueS condof yourEditionfavorite automobile would be preserved across
post backs, thanks to the HttpSessionState object manipulatedISBN:1590590554with the inherited Session property. by Andrew Troel en
Apress © 2003 (1200 pages)
SOURCE The SimpleStateExample files are included under the Chapter 19 subdirectory.
This comprehensive text starts with a brief overview of the
CODE
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
ASP.NET StateC# andManagementthe .NET Platform,TechniquesS cond Edition
by Andrew Troelsen |
ISBN:1590590554 |
ASP.NET provides several mechanisms that you can use to maintain stateful information in your Web
Apress © 2003 (1200 pages)
applications. Specifically, you have the following options:
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Make use of ASP.NET view state.
architectural issues for .NET developers.
Define application-level variables.
Table of Contents
Make use of the application cache.
C# and the .NET Platform, Second Edition
IntroductionDefine session-level variables.
Part One - Introducing C# and the .NET Platform
Interact with cookie data.
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
We'll examine the details of each approach in turn, beginning with the topic of ASP.NET view state.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .RoleNET Platform,of ASPSecond.NETEditionView State
by Andrew Troelsen |
ISBN:1590590554 |
The term view state has been thrown out numerous times here and in the previous chapter without a formal
Apress © 2003 (1200 pages)
definition, so let's demystify this term once and for all. Under classic ASP, Web developers were required to
This comprehensive text starts with a brief overview of the
manually repopulateC# languagethe valuesandofthenthe incomingquickly movesformtowidgetskey echnicalduring andthe process of constructing the outgoing HTTP responsearchitectural. Forissuesexample,for .NETif thedevelopersincoming.HTTP request contained five text boxes with specific values, the *.asp file needed to extract the current values (via the Form or QueryString collections of the Request object) and manually place them back into the HTTP response stream (needless to say, this was
Table of Contents
a drag). If the developer failed to do so, the caller was presented with a set of five empty text boxes!
C# and the .NET Platform, Second Edition
Under ASP.NET, we are no longer required to manually scrape out and repopulate the values contained
Introduction
within the HTML widgets because the ASP.NET runtime will automatically embed a hidden form field
Part One - Introducing C# and the .NET Platform
(named __VIEWSTATE), which will flow between the browser and a specific page. The data assigned to
Chapter 1 - The Philosophy of .NET
this field is a 64-base encoded string that contains a set of name/value pairs that represent the values of
Chapter 2 - Building C# Applications
each GUI widget on the page at hand.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
The System.Web.UI.Page base class' Init event handler is the entity in charge of reading the incoming
Chapter 4 - Object-Oriented Programming with C#
values found within the __VIEWSTATE field to populate the appropriate member variables in the derived
Chapter 5 - Exceptions and Object Lifetime
class (which is why it is risky at best to access the state of a Web widget within the scope of a page's Init
Chapter 6 - Interfaces and Collections event handler).
Chapter 7 - Callback Interfaces, Delegates, and Events
Also, just before the outgoing response is emitted back to the requesting browser, the __VIEWSTATE data
Chapter 8 - Advanc d C# Type Construction Techniques
is used to repopulate the form's widgets, to ensure that the current values of the HTML widgets appear as
Part Three - Programming with .NET Assemblies
they did prior to the previous post back.
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Clearly, the best thing about this aspect of ASP.NET is that it just happens without any work on your part. Of
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
course, you are always able to interact with, and alter, this default functionality if you so choose. To
Part Four - Leveraging the .NET Libraries
understand how to do this, let's see a concrete view state example.
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Demonstrating View State
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
First create a new ASP.NET Web application called ViewStateApp. On your initial *.aspx page, add a single
Chapter 16 - The System.IO Namespace
ASP.NET ListBox Web control and a single Button type. Handle the Click event for the Button to provide a
Chapter 17 - Data Access with ADO.NET
way for the user to post back to the Web server:
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
private void btnDoPostBack_Click(object sender, System.EventArgs e)
Chapter 19 - ASP.NET Web Applications
{
Chapter 20 - XML Web Services
// No-op. This is just here to allow a post back.
Index
}
List of Figures
List of Tables
Now, using the VS .NET Properties window, access the Items property and add four ListItems to the ListBox. The result looks like this:
<asp:ListBox id="myListBox"
style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 64px" runat="server"> <asp:ListItem Value="Item One">Item One</asp:ListItem>
<asp:ListItem Value="Item Two">Item Two</asp:ListItem> <asp:ListItem Value="Item Three">Item Three</asp:ListItem> <asp:ListItem Value="Item Four">Item Four</asp:ListItem>
</asp:ListBox>
Note that we have hard-coded the items in the ListBox directly within the *.aspx file. As you already know, all <asp:> definitions found within an HTML form will automatically render back their HTML representation before the final HTTP response (provided they have the runat="server" attribute).
Now, recall from the previous chapter that the <%@Page%> directive has an optional attribute called
C# and the .NET Platform, Second Edition
enableViewState that by default is set to "true." To disable this behavior, simply update the <%@Page%>
by Andrew Troelsen |
ISBN:1590590554 |
directive as follows: |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
<%@ Page language="c#" Codebehind="ViewStateForm1.aspx.cs"
C# language and then quickly moves to key technical and
AutoEventWireup="false"architectural issuesInherits="ViewStateAppfor .NET developers. .WebForm1"
enableViewState="false"%>
Table of Contents
So, what exactly does it mean to disable view state? The answer is "it depends." Given how we defined the
C# and the .NET Platform, Second Edition
term, you would think that if we disable view state for an *.aspx file, the values within our ListBox would not
Introduction
be remembered between post backs to the Web server. However, if you were to run this application as is,
Part One - Introducing C# and the .NET Platform
you might be surprised to find that the information in the ListBox is retained regardless of how many times
Chapter 1 - The Philosophy of .NET
you post back to the page. In fact, if you examine the source HTML returned to the browser, you may be
Chapter 2 - Building C# Applications
further surprised to see that the hidden __VIEWSTATE field is still present:
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
<form name="Form1" method="post" action="ViewStateForm1.aspx" id="Form1">
Chapter 4 - Object-Oriented Programming with C#
<input type="hidden" name="__VIEWSTATE"
Chapter 5 - Exceptions and Object Lifetime
value="dDwtMjAxOTQ3NDgxNDs7Ps4WZe4amXU/eOtWIWDyPHpPqK7b" />
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
The reason that the view state string is still visible is the fact that the *.aspx file has explicitly defined the
Part Three - Programming with .NET Assemblies
ListBox items within the scope of the HTML <form> tags. Thus, the ListBox items will be autogenerated
Chapter 9 - Understanding .NET Assemblies
each time the Web server responds to the client.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
However, assume that our ListBox is dynamically populated within the code behind file rather than within the
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
HTML <form> definition. First, remove the <asp:ListItem> declarations from the current *.aspx file:
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Ch<asp:ListBoxpter 13 - Buildingid="myListBox"a Better Wind w (Introducing Windows Forms)
Chapterstyle="Z14 --AINDEX:Better Painting102; FrameworkLEFT: 8px;(GDI+)POSITION: absolute; TOP: 64px" runat="server">
</asp:ListBox>
Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Next, fill the list items within the Load event handler within your code behind file:
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
private void Page_Load(object sender, System.EventArgs e)
Chapter 19 - ASP.NET Web Applications
{
Chapter 20 - XML Web Services
if(!IsPostBack)
Index
{
List of Figures
// Fill ListBox dynamically!
List of Tables
myListBox.Items.Add("Item One");
myListBox.Items.Add("Item Two");
myListBox.Items.Add("Item Three");
myListBox.Items.Add("Item Four");
}
}
If you post to this updated page, you will find that the first time the browser requests the page, the values in the ListBox are present and accounted for. However, on post back, the ListBox is suddenly empty. The first rule of ASP.NET view state is that its effect is only realized when you have widgets whose values are dynamically generated through code. If you hard-code values within the *.aspx file's <form> tags, the state of these items is always remembered across post backs (even when you set enableViewState to false for a given page).
Furthermore, view state is most useful when you have a dynamically populated Web widget that always
needs to be repopulated for each and every post back (such as an ASP.NET DataGrid, which is always
C# and the .NET Platform, Second Edition |
|
filled using a database hit). If you did not disable view state for pages that contain such widgets, the entire |
|
by Andrew Troelsen |
ISBN:1590590554 |
state of the grid is represented within the hidden __VIEWSTATE field. Given that complex pages may
Apress © 2003 (1200 pages)
contain numerous ASP.NET Web controls, you can imagine how large this string would become. As the
This comprehensive text starts with a brief overviquitew of the
payload of the HTTP request/response cycle could become heavy, this may become a problem for
C# language and then quickly moves to key technical and
the dial-up Web surfers of the world. In cases such as these, you may find faster throughput if you disable architectural issues for .NET developers.
view state for the page.
If the idea of disabling view state for the entire *.aspx file seems a bit too aggressive, recall that every
Table of Contents
descendent of the System.Web.UI.Control base class inherits the EnableViewState property, which makes
C# and the .NET Platform, Second Edition
it very simple to disable view state on a control-by-control basis:
Introduction
Part One - Introducing C# and the .NET Platform
<asp:DataGrid id="myHugeDynamicallyFilledDataGrid"
Chapter 1 - The Philosophy of .NET
style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 200px"
Chapter 2 - Building C# Applications
runat="server"EnableViewState="false">
Part Two - The C# Programming Language
</asp:DataGrid>
Chapter 3 |
- C# Language Fundamentals |
Chapter 4 |
- Object-Oriented Programming with C# |
Chapter 5 |
- Exceptions and Object Lifetime |
Chapter 6 |
- Interfaces and Collections |
ChapterNote7 Be- CawarellbackthatInterfaces,ASP.NETDelegatpages,reserveand Eventsa small part of the __VIEWSTATE string for internal use.
Given this, you will find that the __VIEWSTATE field will still appear in the client-side browser
Chapter 8 - Advanced C# Type Construction Techniques
even when the entire page (and all the controls) have disabled view state.
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
ChapterAdding10 - CustomProce ses, AppDomains,View StateCont xts,Datand Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartIn additionFour - Leveragingto the EnableViewStatethe .NET Librariesproperty, the System.Web.UI.Control base class also provides an
inherited property named ViewState. Under the hood, this property provides access to a
Chapter 12 - Object Serialization and the .NET Remoting Layer
System.Web.StateBag type, which represents all the data contained within the __VIEWSTATE field. Using
Chapter 13 - Building a Better Window (Introducing Windows Forms)
the indexer of the StateBag type, you can embed custom information within the hidden __VIEWSTATE form
Chapter 14 - A Better Painting Framework (GDI+)
field using a set of name/value pairs. By way of a simple example:
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
private void btnAddToVS_Click(object sender, System.EventArgs e)
Chapter 17 - Data Access with ADO.NET
{
Part Five - Web Applications and XML Web Services
ViewState["CustomViewStateItem"] = "Some user data";
Chapter 18 - ASP.NET Web Pages and Web Controls
lblVSValue.Text = (string)ViewState["CustomViewStateItem"];
Chapter 19 - ASP.NET Web Applications
}
Chapter 20 - XML Web Services
Index
List of Figures
Because the System.Web.StateBag type has been designed to operate on any type-derived System.Object,
List of Tables
when you wish to access the value of a given key, you will need to explicitly cast it into the correct underlying data type (in this case, a System.String). Beware, however, that values placed within the __VIEWSTATE field cannot literally be any object. Specifically, the only valid types are strings, integers, Booleans, ArrayList, Hashtable, or an array of these types.
So, given that *.aspx pages may insert custom bits of information into the __VIEWSTATE string, the next logical question is when you would want to do so. Most of the time, custom view state data is best suited for user-specific preferences. For example, you may establish a point of view state data that specifies how a user wishes to view the UI of a DataGrid (such as a sort order). View state data is not well suited for fullblown user data such as items in a shopping cart, cached DataSets, or whatnot. When you need to store this sort of complex information, you are required to work with session data. Before we get to that point, we need to understand the role of the Global.asax file.
SOURCE The ViewStateApp files are included under the Chapter 19 subdirectory.
CODE
The Role ofC#theandGlobalthe .NET .Platform,asax FileSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
At this point, an ASP.NET application may seem to be little more than a set of *.aspx files and their respective
Apress © 2003 (1200 pages)
Web controls. While you could build a Web application by simply linking a set of related Web pages, you will
This comprehensive text starts with a brief overview of the
most likely need aC#waylanguageto interactand withthenthequicklyWebmovesapplicationto keyastechnicala wholeand. To this end, your ASP.NET Web applications mayarchitecturalchoose to includeissues anfor optional.NET deveclassoperstype. that derives from System.Web.HttpApplication. Simply put, this class is just about as close to a traditional double-clickable *.exe as we can get in the world of ASP.NET.
Table of Contents
C#Byanddefault,the .NETASPPlatform,.NET WebSecondprojectsEditioncreated with VS .NET receive a Global.asax file and an associated code
behind file (Global.asax.cs). If you open the Global.asax file within VS .NET, you will see that the designer is
Introduction
little more than a glorified component tray (Figure 19-2).
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 19-2: The Global.asax designer
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartWhileFouryou- Ltechnicallyveraging thecould.NETplaceLibrariesGUI-based widgets onto this designer, they would be of little use as they are Chaptnot renderedr 12 - Obackje t Serializationinto the HTTPandresponsethe .NET streamRemoting. Rather,Lay this component tray is used to hold any application-
level widgets you wish to define within your HttpApplication-derived class (SqlConnections, SqlCommands,
Chapter 13 - Building a Better Window (Introducing Windows Forms)
EventLogs, and so forth). Like a Formor Page-derived type, items placed on the Global.asax component tray
Chapter 14 - A Better Painting Framework (GDI+)
will result in a member variable in the associated code behind file.
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
If you open the code behind file for an unaltered Global.asax, you see the following definition for a class named
Chapter 17 - Data Access with ADO.NET
Global that derives from System.Web.HttpApplication:
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
public class Global : System.Web.HttpApplication
Chapter 19 - ASP.NET Web Applications
{
Chapter 20 - XML Web Services
protected void Application_Start(Object sender, EventArgs e){}
Index protected void Session_Start(Object sender, EventArgs e){}
List of Figures |
Application_BeginRequest(Object sender, EventArgs e){} |
protected void |
|
List of Tables |
Application_EndRequest(Object sender, EventArgs e){} |
protected void |
protected void Session_End(Object sender, EventArgs e){} protected void Application_End(Object sender, EventArgs e){} protected void Application_Error(Object sender, EventArgs e){}
protected void Application_AuthenticateRequest(Object sender, EventArgs e){
}
The members defined inside the Global class are in reality event handlers that allow you to interact with application-level (and session-level) events. Table 19-1 documents the role of each member.
Table 19-1: Core Types of the System.Web Namespace
|
|
|
|
|
|
|
|
Event HandlerC# andof thehe .NET Platform,MeaningSecond inEditionLife |
|
||||
|
Global Typeby Andrew Troelsen |
|
ISBN:1590590554 |
|
||
|
|
|
|
|
|
|
|
|
Apress © 2003 (1200 pages) |
|
This event handler is called the very first time the Web |
|
|
|
Application_Start() |
|
|
|
||
|
|
This comprehensive text |
|
starts with a brief overview of the |
|
|
|
|
|
|
|
application is launched. Thus, this event will fire exactly once |
|
|
|
C# language and then quickly moves to key technical and |
|
|||
|
|
architectural issues for .NEToverdevelopers.the lifetime of a Web app. This is an ideal place to define |
|
|||
|
|
|
|
|
application-level data used throughout your Web application. |
|
|
|
|
|
|
||
|
Application_End() |
|
|
Called when the application is shutting down. This will occur |
|
|
Table of Contents |
|
|
when the last user times out or if you manually shut down the |
|
||
C# and the .NET Platform, Second Edition |
|
|
||||
|
app via IIS. |
|
||||
|
|
|
|
|
|
|
|
Introduction |
|
|
|
|
|
|
|
|
|
|
||
PartSessionOne - Introducing_Start() |
C# and the .NET PlatformFired when a new user logs onto your application. Here you |
|
||||
Chapter 1 |
- The Philosophy of .NET |
|
may establish any user-specific data points. |
|
||
|
|
|
|
|
||
|
Chapter 2 - Building C# Applications |
|
Fired when a user's session has terminated. |
|
||
|
Session_End |
|
|
|
||
Part Two - The C# Programming Language |
|
|
|
|||
|
|
|
||||
ChapterApplication3 - C#_BeginRequest()Language Fundamentals |
|
These events are fired each and every time an HTTP request |
|
|||
Chapter 4 - Object-Oriented Programming |
|
withbeginsC# and ends, and allow you to interact with (and possibly |
|
|||
|
Application_EndRequest() |
|
modify) the current request data. Once the EndRequest() |
|
||
Chapter 5 - Exceptions and Object Lifetime |
|
|
||||
|
Chapter 6 |
- Interfaces and Collections |
|
event handler has completed, the response is sent. |
|
|
|
|
|
||||
|
Chapter 7 - Callback Interfaces, Delegates, |
|
and Events |
|
||
|
Application_AuthenticateRequest() |
|
Called when ASP.NET is just about to perform any |
|
||
|
Chapter 8 |
- Advanced C# Type Construction |
|
Tech iques |
|
|
|
|
|
|
|
authentication on the current request. This can be handy if you |
|
Part Three - Programming with .NET Assemblies |
|
|||||
|
|
|
|
|
want to perform any customized authentication actions in |
|
Chapter 9 - Understanding .NET Assembliesaddition to the standard ASP.NET logic (not covered here). |
|
|||||
|
|
|
|
|
||
|
Chapter 10 - Processes, AppDomains, Contexts, and Threads |
|
||||
|
Application_Error() |
|
|
This is a global error handler that will be called when an |
|
|
|
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming |
|
||||
Part Four - Leveraging the .NET Libraries |
|
unhandled exception is thrown by the Web application. |
|
|||
|
|
|
Chapter 12 - Object Serialization and the .NET Remoting Layer
Your Global class may define numerous other event handlers. However, the members seen in Table 19-1 fit th
Chapter 13 - Building a Better Window (Introducing Windows Forms) bill for this chapter (see online Help for further details).
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
The Global Last Chance Exception Event Handler
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
First up, let me point out the role of the Application_Error() event handler. Recall that a specific page may
Part Five - Web Applications and XML Web Services
handle the Error event to process any unhandled exception that occurred within the scope of the page itself. In
Chapter 18 - ASP.NET Web Pages and Web Controls
similar light, the Application_Error() event handler is the final place to handle an exception that was not handled
Chapter 19 - ASP.NET Web Applications
by a specific page. As with the page level Error event, you are able to access the specific System.Exception
Chapter 20 - XML Web Services using the inherited Server property:
Index
List of Figures
protected void Application_Error(Object sender, EventArgs e)
List of Tables
{
Exception ex = Server.GetLastError();
Response.Write(ex.Message);
Server.ClearError();
}
Given that the Application_Error() event handler is the last chance exception handler for your Web application, the odds are that you would rather not report the error to the user, but rather log this information to the Web server's event log. For example:
using System.Diagnostics;
...
protected void Application_Error(Object sender, EventArgs e)
{
// Log last error to event log.
Exception ex = Server.GetLastError();
C# and the .NET Platform, Second Edition
EventLog ev = new EventLog("Application");
by Andrew Troelsen ISBN:1590590554 ev.WriteEntry(ex.Message, EventLogEntryType.Error);
Apress © 2003 (1200 pages)
Server.ClearError();
This comprehensive text starts with a brief overview of the
Response.Write("This app has bombed. Sorry!");
C# language and then quickly moves to key technical and
}
architectural issues for .NET developers.
TableTheofHttpApplicationContents Base Class
C# and the .NET Platform, Second Edition
The Global class derives from the System.Web.HttpApplication base class, which supplies the same sort of
Introduction
functionality as the System.Web.UI.Page type. Table 19-2 documents the key members of interest.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Table 19-2: Key Members Defined By the System.Web.HttpApplication Type
Chapter 2 - Building C# Applications
|
|
|
|
|
|
Part Two - The C# Programming Language |
Meaning in Life |
|
|
||
|
Select Properties of the |
|
|
||
Chapter 3 |
- C# Language Fundamentals |
|
|
|
|
|
HttpApplication Type |
|
|
|
|
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
|
|
|
|
||||
|
ChapterApplication5 - Exceptions and Object Lifetime |
This property allows you to interact with application-level |
|
|
|
|
Chapter 6 |
- Interfaces and Collections |
variables, using the exposed HttpApplicationState type. |
|
|
|
|
|
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
|
|
Request |
|
This property allows you to interact with the incoming HTTP |
|
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
|
|
|
|
request (via HttpRequest). |
|
|
|
|
|
|
|
|
Part Three - Programming with .NET Assemblies |
This property allows you to interact with the incoming HTTP |
|
|
||
|
Response |
|
|
||
Chapter 9 |
- Understanding .NET Assemblies |
response (via HttpResponse). |
|
|
|
|
|
|
|
|
|
|
Chapter 10 |
- Processes, AppDomains, Contexts, |
and Threads |
|
|
|
|||||
|
Chapter 11 |
- Type Reflection, Late Binding, and |
Attribute-Based Programming |
|
|
|
Server |
|
This property gets the intrinsic server object for the current |
|
|
Part Four - Leveraging the .NET Libraries |
request (via HttpServerUtility). |
|
|
||
|
|
|
|
|
|
|
Chapter 12 |
- Object Serialization and the .NET |
Remoting Layer |
|
|
|
Session |
|
This property allows you to interact with session-level |
|
|
|
Chapter 13 |
- Building a Better Window (Introducing Windows Forms) |
|
|
|
|
|
|
variables, using the exposed HttpSessionState type. |
|
|
|
Chapter 14 |
- A Better Painting Framework (GDI+) |
|
|
|
Chapter 15 |
- Programming with Windows Forms Controls |
||||
Chapter 16 |
- The System.IO Namespace |
|
|
|
|
Chapter 17 |
- Data Access with ADO.NET |
|
|
|
|
Part Five - Web Applications and XML Web Services |
|||||
Chapter 18 |
- ASP.NET Web Pages and Web Controls |
||||
Chapter 19 |
- ASP.NET Web Applications |
|
|
|
|
Chapter 20 |
- XML Web Services |
|
|
|
|
Index |
|
|
|
|
List of Figures
List of Tables
UnderstandingC# andthet .Application/SessionNET P atform, Second Ed tion Distinction
by Andrew Troelsen |
ISBN:1590590554 |
Under ASP.NET, application state is represented by the HttpApplicationState type. This class enables you to
Apress © 2003 (1200 pages)
share global information across all users who are logged onto your ASP.NET application. Not only can
This comprehensive text starts with a brief overview of the
application data beC#sharedlanguagebyandall usersth n quicklyon yourmovessite, butto keyif onet chnicaluser changesand the value of an application-level da point, the changearchitis seencturalby allissuesothersforon.NETtheirdevnextloperspost. back.
On the other hand, session state is used to remember information for a specific user (again, such as items in a
Tableshoppingof Contentscart). Physically, a user's session state is represented by the HttpSessionState type. When a new use C#logsandontothean.NETASPPlatform,.NET WebS condapplication,Edition the runtime will automatically assign that user a new session ID, which
by default will expire after 20 minutes of inactivity. Thus, if 20,000 users are logged onto your site, you have
Introduction
20,000 distinct HttpSessionState objects, each of which is assigned a unique session ID. The relationship
Part One - Introducing C# and the .NET Platform
between a Web application and Web sessions is shown in Figure 19-3.
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter |
|
Chapter |
|
Chapter |
Programming |
Part |
|
Chapter
Figure 19-3: The Application/Session state distinction
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
As you may know, under classic ASP, applicationand session-state data is represented using distinct COM
Chapter 15 - Programming with Windows Forms Controls
objects (e.g., Application and Session). Under ASP.NET, Page-derived types as well as the HttpApplication typ
Chapter 16 - The System.IO Namespace
make use of identically named properties (i.e., Application and Session), which expose the underlying
Chapter 17 - Data Access with ADO.NET
HttpApplicationState and HttpSessionState types.
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Maintaining Application-Level State Data
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
The HttpApplicationState enables developers to share global information across multiple sessions in an
Index
ASP.NET application. For example, you may wish to maintain an application-wide connection string that can be
List of Figures
used by all pages, a common DataSet used by multiple pages, or any other piece of data that needs to be
List of Tables
accessed on an application-wide scale. Table 19-3 describes some core members of this type.
Table 19-3: Members of the HttpApplicationState Type
|
|
|
|
|
|
|
|
HttpApplicationStateC# and the .NET |
|
Platform,MeaningSecondin LifeEdition |
|
||
|
Member |
by Andrew Troelsen |
|
|
ISBN:1590590554 |
|
|
|
|
|
|
|
|
|
AllKeys |
Apress © 2003 (1200 |
pages) |
|||
|
This comprehensive |
|
|
This property returns an array of System.String types that represent |
|
|
|
|
|
text starts with a brief overview of the |
|
||
|
|
|
|
|
all the names in the HttpApplicationState type. |
|
|
|
C# language and |
|
then quickly moves to key technical and |
|
|
|
Count |
architectural issues |
|
for .NET developers. |
|
|
|
|
|
|
This property gets the number of item objects in the |
|
|
|
|
|
|
|
HttpApplicationState type. |
|
|
|
|
|
|
|
|
Table of Contents |
|
|
This method allows you to add a new name/value pair into the |
|
||
|
Add() |
|
|
|
|
|
C# and the .NET Platform, Second EditionHttpApplicationState type. Do note that this method is typically not |
|
|||||
Introduction |
used in favor of the indexer of the HttpApplicationState class. |
|
||||
|
|
|
|
|
||
Part One - Introducing C# and the .NET Platform |
|
|||||
|
Clear() |
|
|
|
Deletes all items in the HttpApplicationState type. This is functionally |
|
Chapter 1 |
- The Philosophy of .NET |
equivalent to the RemoveAll() method. |
|
|||
|
Chapter 2 - Building C# Applications |
|
|
|
|
|
|
|
|
|
|
||
PartLock()Two - The C# Programming LanguageThese two methods are used when you wish to alter a set of |
|
|||||
Chapter 3 - C# Language Fundamentalsapplication variables in a thread-safe manner. |
|
|||||
|
Unlock() |
|
|
|
|
|
|
|
|
|
|
||
|
Chapter 4 - Object-Oriented Programming with C# |
|
||||
|
Remove() |
Removes a specific item (by string name) within the |
|
|||
|
Chapter 5 - Exceptions and Object Lifetime |
|
||||
|
|
|
|
|
HttpApplicationState type. RemoveAt() removes the item via a |
|
|
ChapterRemoveAt()6 - Interfaces and Collections |
|
||||
|
|
|
|
|
numerical indexer. |
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
Chapter 8 - Advanced C# Type Construction Techniques
When you need to create data members that can be shared among all active sessions, you need to establish a
Part Three - Programming with .NET Assemblies
set of name/value pairs. In most cases, the most natural place to do so is within the Application_Start() event
Chapter 9 - Understanding .NET Assemblies
handler of the HttpApplication-derived type. For example:
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
protected void Application_Start(Object sender, EventArgs e)
Part Four - Leveraging the .NET Libraries
{
Chapter 12 - Object Serialization and the .NET Remoting Layer
// Set up some application variables.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Application["SalesPersonOfTheMonth"] = "Chucky";
Chapter 14 - A Better Painting Framework (GDI+)
Application["CurrentCarOnSale"] = "Colt";
Chapter 15 - Programming with Windows Forms Controls
Application["MostPopularColorOnLot"] = "Black";
Chapter 16 - The System.IO Namespace
}
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
ChapterDuring18the-lifetimeASP.NETofWebyourPagWebs applicationnd Web Controls(which is to say, until the Web application is manually shut down or
until the final user times out), any user (on any page) may access these values as necessary. Assume you hav
Chapter 19 - ASP.NET Web Applications
a page that will display the current discount car within a Label via a button click:
Chapter 20 - XML Web Services Index
Listprivateof Figuresvoid btnShowAppVariables_Click(object sender, System.EventArgs e)
{
List of Tables
//Must cast the returned System.Object
//to a System.String! lblAppVariables.Text =
(string)Application["CurrentCarOnSale"];
}
Like the ViewState property, notice how we must cast the value returned from the HttpApplicationState type into the correct underlying type. Now, given that the HttpApplicationState type can hold any type, it should stand to reason that you can place custom types (or any .NET type) within your site's application state.
To illustrate this technique, create a new ASP.NET Web application named AppState. Assume you would rathe maintain the three current application variables within a strongly typed object named CarLotInfo:
public class CarLotInfo
{
C# and the .NET Platform, Second Edition
public CarLotInfo(string s, string c, string m)
ISBN:1590590554
{
Apress © 2003 (1200 pages)
salesPersonOfTheMonth = s;
currentCarOnSaleThis comp ehensive text starts with a brief overview of the
= c;
C# language and then quickly moves to key technical and mostPopularColorOnLot = m;
architectural issues for .NET developers.
}
// Public for easy access.
public string salesPersonOfTheMonth;
Table of Contents
public string currentCarOnSale;
C# and the .NET Platform, Second Edition
public string mostPopularColorOnLot;
Introduction
}
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
With this helper class in place, we could modify the Application_Start() event handler as follows:
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
protected void Application_Start(Object sender, EventArgs e)
Chapter 4 - Object-Oriented Programming with C#
{
Chapter 5 - Exceptions and Object Lifetime
// Place a custom object in the application data sector.
Chapter 6 - Interfaces and Collections
Application["CarSiteInfo"] =
Chapter 7 - Callback Interfaces, Delegates, and Events
new CarLotInfo("Chucky", "Colt", "Black");
Chapter} 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
and then access the information using the public field data within a server-side event handler:
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartprivateFour - Leveragingvoid btnShowAppVariablesthe .NET Libra ies _Click(object sender, System.EventArgs e)
{
Chapter 12 - Object Serialization and the .NET Remoting Layer
CarLotInfo appVars =
Chapter 13 - Building a Better Window (Introducing Windows Forms)
((CarLotInfo)Application["CarSiteInfo"]);
Chapter 14 - A Better Painting Framework (GDI+)
string appState =
Chapter 15 - Programming with Windows Forms Controls
string.Format("<li>Car on sale: {0}</li>",
Chapter 16 - The System.IO Namespace
appVars.currentCarOnSale);
Chapter 17 - Data Access with ADO.NET
appState +=
Part Five - Web Applications and XML Web Services
string.Format("<li>Most popular color: {0}</li>",
Chapter 18 - ASP.NET Web Pages and Web Controls appVars.mostPopularColorOnLot);
Chapter 19 - ASP.NET Web Applications appState +=
Chapter 20 - XML Web Services
string.Format("<li>Big shot SP: {0}</li>",
Index
appVars.salesPersonOfTheMonth);
List of Figures
lblAppVariables.Text = appState;
List of Tables
}
If you were now to run this page, you would find that a list of each application variable is displayed on the page' Label type.
Modifying Application Data
You may programmatically update or delete any or all members using members of the HttpApplicationState typ during the execution of your Web application. For example, to delete a specific item, simply call the Remove() method. If you wish to destroy all application-level data, call RemoveAll():
// Remove a single item via string name.
Application.Remove("SomeItemIDontNeed");
// Destroy all application data!
Application.RemoveAll();
C# and the .NET Platform, Second Edition
If you wish to simplyby AndrewchangeTrothelsenvalue of an existing applicationISBN:1590590554-level variable, you only need to make a new assignment to theApressdata item© 2003in(1200questionpages). Assume your page now supports a new Button type that allows your us
to change the current hotshot salesperson. The Click event handler is as you would expect:
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
private void btnSetNewSP_Click(object sender, System.EventArgs e)
{
// Set the new Salesperson.
Table of Contents
((CarLotInfo)Application["CarSiteInfo"]).salesPersonOfTheMonth
C# and the .NET Platform, Second Edition
= txtNewSP.Text;
Introduction
}
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChapterIf you ran2 the- BuildingWeb application,C# Applicationsyou would now find the application-level variable has been updated. Furthermor
PartgivenTwothat- TheapplicationC# Pr grammingvariablesLanguageare accessible from all user sessions, if you were to launch three or four
Chapterinstances3 of- C#yourLanguageWeb browser,Fundamentalsyou would find that if one instance changes the current hotshot salesperson,
Cheachpterof4the- otherObj ctbrowsers-Oriented willProgrammingdisplay thewithnewC#value on post back.
Chapter 5 - Exceptions and Object Lifetime
Understand that if you have a situation where a set of application-level variables must be updated as a unit, you
Chapter 6 - Interfaces and Collections
risk the possibility of data corruption (given that it is technically possible that an application-level data point may be changed while another user is attempting to access it!). While you could take the long road and manually lo down the logic using threading primitives of the System.Threading namespace, the HttpApplicationState type h
two methods (Lock() and Unlock()) that automatically ensure thread safety:
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
// Safely access related application data.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Application.Lock();
Part Four - Leveraging the .NET Libraries
Application["SalesPersonOfTheMonth"] = "Maxine";
Chapter 12 - Object Serialization and the .NET Remoting Layer
Application["CurrentBonusedEmployee"] = Application["SalesPersonOfTheMonth"
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Application.Unlock();
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
ChapterNote17 Much- DatalikeAccessthe C#withlockADOstatement,.NET if an exception occurs after the call to Lock() but before the call to
Part Five - WebUnlock(),Applicationsthe pieceandofXMLapplicationWeb Servic-levelsdata that was being altered will automatically be freed.
Chapter 18 - ASP.NET Web Pages and Web Controls
ChaptInterceptingr 19 - ASP.NETWebb ApplicationsApplication Shutdown
Chapter 20 - XML Web Services
IndexThe HttpApplicationState type is designed to maintain the values of the items it contains until one of two situatio Listoccurs:of Figurtheslast user on your site times out (or manually logs out) or someone manually shuts down the Web vi
IIS. In each case, the Application_Exit() method of the HttpApplication-derived type will automatically be called.
List of Tables
Within this event handler you are able to perform whatever sort of clean-up code is necessary:
protected void Application_End(Object sender, EventArgs e)
{
//Write current application variables
//to a database or whatever else you need to do...
}
SOURCE The AppState files are included under the Chapter 19 subdirectory.
CODE
Working with the Application Cache |
|
C# and the .NET Pl tform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
ASP.NET provides a second and more flexible manner to handle application-wide data. As you recall, the
Apre s © 2003 (1200 pages)
values within the HttpApplicationState object remain in memory as long as your Web application is alive and
This comprehensive text starts with a brief overview of the
kicking. Sometimes,C# languagehowever,andyouthenmayquicklywish tomovesmaintainto keya piecet hnicalof applicationand data only for a specific period of time. For example,architecturalyou may wishis uesto forcache.NETandevelopersADO.NET. DataSet that is only valid for 5 minutes. After that time,you may want to obtain a fresh DataSet to account for possible user modifications. While it is technically possible to build this infrastructure using HttpApplicationState and some sort of hand-crafted monitor, your
Table of Contents
task is greatly simplified using the ASP.NET application cache.
C# and the .NET Platform, Second Edition
As suggested by its name, the ASP.NET System.Web.Caching.Cache object (which is accessible via the
Introduction
Context.Cache property) allows you to define an object that is accessible by all users (from all pages) for a
Part One - Introducing C# and the .NET Platform
fixed amount of time. In its simplest form, interacting with the cache looks identical to interacting with the
Chapter 1 - The Philosophy of .NET
HttpApplicationState type:
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter// Add3 an- C#itemLanguageto theFundamentalscache.
// This item will *not* expire.
Chapter 4 - Object-Oriented Programm ng with C#
Context.Cache["SomeStringItem"] = "This is the string item";
Chapter 5 - Exceptions and Object Lifetime
string s = (string)Context.Cache["SomeStringItem"];
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Note If you wish to access the Cache from within the Global class, you are required to use the Context
Chapter 9 - Understanding .NET Assemblies
object. However, if you are within the scope of a System.Web.UI.Page-derived type, you can make
Chapter 10 - Processes, AppDomains, Contexts, and Threads use of the Cache object directly.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartNow,FounderstandLeveragingthattheif you.NEThaveLibrariesno interest in automatically updating (or removing) an application-level data Chapterpoint (as12seen- Objecthere),Serializationthe Cacheandobjectthe .isNETof littleRemotingbenefit,Layeras you can directly use the HttpApplicationState type.
However, when you do wish to have a data point destroyed after a fixed point of time—and optionally be
Chapter 13 - Building a Better Window (Introducing Windows Forms)
informed when this occurs—the Cache type is extremely helpful.
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
The System.Web.Caching.Cache class defines only a small number of members beyond the type's indexer.
Chapter 16 - The System.IO Namespace
For example, the Add() method can be used to insert a new item into the cache that is not currently defined (if
Chapter 17 - Data Access with ADO.NET
the specified item is already present, Add() does nothing). The Insert() method will also place a member into
Part Five - Web Applications and XML Web Services
the cache. If, however, the item is currently defined, Insert() will replace the current item with the new type.
Chapter 18 - ASP.NET Web Pages and Web Controls
Given that this is most often the behavior you will desire, I'll focus on the Insert() method exclusively.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Fun with Data Caching
Index
List of Figures
Let's see an example. To begin, create a new ASP.NET Web application named CacheState. Like an
List of Tables
application-level variable maintained by the HttpApplicationState type, the Cache may hold any System.Object-derived type, and is often populated within the Application_Start() event handler. For this example, the goal is to automatically update the contents of a DataSet every 15 seconds. The DataSet in question will contain the current set of records from the Inventory table of the Cars database created during our discussion of ADO.NET. Given these stats, update your Global class type as so (code analysis to follow):
public class Global : System.Web.HttpApplication
{
...
// Define a static level Cache member variable.
private static Cache theCache;
protected void Application_Start(Object sender, EventArgs e)
{
// First assign the static 'theCache' variable.
theCache = Context.Cache;
C# and the .NET Platform, Second Edition |
|
||
// When the application starts up, |
ISBN:1590590554 |
||
by An |
rew Troelsen |
|
|
// read |
the current records in the |
|
|
Apress © 2003 (1200 pag s) |
|
||
// Inventory table |
of the Cars DB. |
|
SqlConnectionThis comprehe sivecn text= newstartsSqlConnectionwith a bri f overview of the
C# language and then quickly moves to key technical and
("data source=localhost;initial catalog=Cars; user id ='sa';pwd=''");
architectural issues for .NET developers.
SqlDataAdapter dAdapt =
new SqlDataAdapter("Select * From Inventory", cn);
DataSet theCars = new DataSet();
Table of Contents
dAdapt.Fill(theCars, "Inventory");
C# and the .NET Platform, Second Edition
Introduction
// Now store DataSet in the cache.
Part One - Introducing C# and the .NET Platform
theCache.Insert("AppDataSet",
Chapter 1 - The Philosophy of .NET
theCars, null,
Chapter 2 - Building C# Applications
DateTime.Now.AddSeconds(15),
Part Two - The C# Programming Language
Cache.NoSlidingExpiration,
Chapter 3 |
- C# Language Fundamentals |
|
|
|
CacheItemPriority.Default, |
|
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
|
|
new CacheItemRemovedCallback(UpdateCarInventory)); |
||
Chapter 5 |
- Exceptions and Object Lifetime |
|
|
} |
|
|
|
Chapter 6 |
- Interfaces and Collections |
|
delegate. |
Chapter //7 |
-TheCallbacktargetInterfaces,for Delthegates,CacheItemRemovedCallbackand Events |
||
Chapter static8 - AdvancedvoidC#UpdateCarInventory(stringType Construction Techniques |
key, object item, |
||
Part Three - ProgrammingCacheItemRemovedReasonwith .NET Assembliesreason) |
|
|
|
Chapter {9 |
- Understanding .NET Assemblies |
|
|
Chapter 10 |
- Processes,// PopulateAppDomains,the Contexts,DataSet.and Threads |
|
|
Chapter 11 |
- TypeSqlConnectionReflection, Late Binding,cn = newand AttributeSqlConnection-Based Programming |
("data source=localhost;initial catalog=Cars; user id ='sa';pwd=''");
Part Four - Leveraging the .NET Libraries
SqlDataAdapter dAdapt =
Chapter 12 - Object Serialization and the .NET Remoting Layer
new SqlDataAdapter("Select * From Inventory", cn);
Chapter 13 - Building a Better Window (Introducing Windows Forms)
DataSet theCars = new DataSet();
Chapter 14 - A Better Painting Framework (GDI+) dAdapt.Fill(theCars, "Inventory");
Chapter 15 - Programming with Windows Forms Controls
// Now store in the cache.
Chapter 16 - The System.IO Namespace theCache.Insert("AppDataSet",
Chapter 17 - Data Access with ADO.NET theCars, null,
Part Five - Web Applications and XML Web Services
DateTime.Now.AddSeconds(15),
Chapter 18 - ASP.NET Web Pages and Web Controls
Cache.NoSlidingExpiration,
Chapter 19 - ASP.NET Web Applications
CacheItemPriority.Default,
Chapter 20 - XML Web Services
new CacheItemRemovedCallback(UpdateCarInventory));
Index }
List...of Figures
List} of Tables
First, notice that the Global class type has defined a static level Cache member variable. The reason is that we have also defined a static-level function (UpdateCarInventory()) that needs to access the Cache (recall that static members do not have access to inherited members, therefore, we can't use the Context property!)
Inside the Application_Start() event handler, we fill a DataSet and place the object within the application cache. As you would guess, the Context.Cache.Insert() method has been overloaded a number of times. Here we have supplied a value for each possible parameter:
// Now store in the cache. |
// Name used |
to identify item in the cache. |
|||
theCache.Add("AppDataSet", |
|||||
theCars, |
// |
Object to |
put In |
the |
cache. |
null, |
// |
Any dependencies |
for |
this object? |
DateTime.Now. AddSeconds(15), |
// How long |
item will be in cache. |
|
C# and the .NET Platform, Second Edition |
sliding time? |
||
Cache.NoSlidingExpiration, |
// |
Fixed or |
|
by Andrew Troelsen |
// |
ISBN:1590590554 |
|
CacheItemPriority.Default, |
Priority |
level of cache item. |
Apress © 2003 (1200 pages)
// Delegate for CacheItemRemove event
new CacheItemRemovedCallback(UpdateCarInventory));This comprehensive text starts with a brief over iew of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
The first two parameters simply make up the name/value pair of the item. Parameter three allows you to
define a CacheDependency type (which is null in this case, as we do not have any other entities in the cache
Table of Contents
that are dependent on the DataSet).
C# and the .NET Platform, Second Edition
IntroductionNote The ability to define a CacheDependency type is quite interesting. For example, you could establish
Part One - Introducinga dependencyC# andbetweenthe .NETa memberPlatformand an external file. If the contents of the file were to change, the
Chapter 1 type- ThecanPhilosophybe automaticallyof .NET updated. Check out online Help for further details.
Chapter 2 - Building C# Applications
The next three parameters are used to define the amount of time the item will be allowed to remain in the
Part Two - The C# Programming Language
application cache as well as its level of priority. Here, we specified the read-only Cache.NoSlidingExpiration
Chapter 3 - C# Language Fundamentals
field, which informs the cache that the specified time limit (15 seconds) is absolute. Finally, and most important for this example, we created a new CacheItemRemovedCallback delegate type, and passed in the name of
the method to call when the DataSet is purged. As you can see from the signature of the
Chapter 6 - Interfaces and Collections
UpdateCarInventory() method, the CacheItemRemovedCallback delegate can only call methods that match
Chapter 7 - Callback Interfaces, Delegates, and Events the following signature:
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
static void UpdateCarInventory(string key, object item,
Chapter 9 - Understanding .NET Assemblies
CacheItemRemovedReason reason)
Chapter 10 - Processes, AppDomains, Contexts, and Threads
{ ... }
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
ChapterSo, at this12 -point,ObjectwhenSerializationthe applicationand thestarts.NET Remotingup, the DataSetLayer is populated and cached. Every 15 seconds the
ChDataSetpter 13is-purged,BuildingupdaBetedter andWindowreinser(Intedroducinginto theWindowscache.Forms)To see the effects of doing this, we need to create a
ChPagept rthat14 -allowsA BetterforPaintingsome degreeFrameworkof user(GDI+)interaction.
Chapter 15 - Programming with Windows Forms Controls
ChapterModifying16 - The Systthem*.IOaspxNamespaceFile
Chapter 17 - Data Access with ADO.NET
PartUpdateFive the- WebUI Applicationsof your initialand*.aspxXMLfileWebasServicesshown in Figure 19-4.
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter
Chapter
Index
List of
List of
Figure 19-4: The cache application GUI
In the page's Load event handler, configure your DataGrid to display the current contents of the cached DataSet the first time the user posts to the page:
private void Page_Load(object sender, System.EventArgs e)
C# and the .NET Platform, Second Edition
{
by Andrew Troelsen |
ISBN:1590590554 |
if(!IsPostBack)
Apress © 2003 (1200 pages)
{
This comprehensive text starts with a brief overview of the carsDataGrid.DataSource = (DataSet)Cache["AppDataSet"];
C# language and then quickly moves to key technical and
carsDataGrid.DataBind(); architectural issues for .NET developers.
}
}
Table of Contents
C# and the .NET Platform, Second Edition
In the Click event handler of the Add this Car button, insert the new record into the Cars database using an
Introduction
ADO.NET SqlCommand object. Once the record has been inserted, call a helper function named
RefreshGrid(), which will update the UI via an ADO.NET SqlDataReader. Here are the methods in question:
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
private void btnAddNewCar_Click(object sender, System.EventArgs e)
Part Two - The C# Programming Language
{
Chapter 3 - C# Language Fundamentals
// Update the Inventory table
Chapter 4 - Object-Oriented Programming with C#
// and call RefreshGrid().
Chapter 5 - Exceptions and Object Lifetime
SqlConnection cn = new SqlConnection();
Chapter 6 - Interfaces and Collections cn.ConnectionString =
Chapter 7 - Callback Interfaces, Delegates, and Events
"User ID=sa;Pwd=;Initial Catalog=Cars;" +
Chapter 8 - Advanced C# Type Construction Techniques
"Data Source=(local)";
Part Three - Programming with .NET Assemblies
cn.Open();
Chapter 9 - Understanding .NET Assemblies
string sql;
Chapter 10 - Processes, AppDomains, Contexts, and Threads
SqlCommand cmd;
Chapter //11 -InsertType Reflection,new CarLate. Binding, and Attribute-Based Programming
Part Foursql- Leveraging= stringthe.Format.NET Libraries
Chapter 12 - Object("INSERTSerializationINTOandInventory(CarID,the .NET Remoting LayerMake, Color, PetName) VALUES" +
Chapter 13 - Building"('{0}',a Better'{1}',Window'{2}',(Introducing'{3}')",Windows Forms)
txtCarID.Text, txtCarMake.Text,
Chapter 14 - A Bet er Painting Framework (GDI+)
txtCarColor.Text, txtCarPetName.Text);
Chapter 15 - Programming with Windows Forms Controls
cmd = new SqlCommand(sql, cn);
Chapter 16 - The System.IO Namespace
cmd.ExecuteNonQuery();
Chapter 17 - Data Access with ADO.NET
cn.Close();
Part Five - Web Applications and XML Web Services
RefreshGrid();
Chapter 18 - ASP.NET Web Pages and Web Controls
}
Chapter 19 - ASP.NET Web Applications
private void RefreshGrid()
Chapter 20 - XML Web Services
{
Index
// Populate grid.
List of Figures
SqlConnection cn = new SqlConnection();
List of Tables
cn.ConnectionString =
"User ID=sa;Pwd=;Initial Catalog=Cars;Data Source=(local)"; cn.Open();
SqlCommand cmd = new SqlCommand("Select * from Inventory", cn); carsDataGrid.DataSource = cmd.ExecuteReader(); carsDataGrid.DataBind();
cn.Close();
}
Now, to test the use of the cache, launch two instances of your Web browser and navigate to this *.aspx page. At this point, you should see that both DataGrids display identical information. From one instance of the browser, add a new Car. Obviously, this results in an updated DataGrid viewable from the browser that initiated the post back.
From browser two, click the Refresh button. You should not see the new item, given that the Page.Load event
handler is reading directly from the cache. (If you did see the value, the 15 seconds had already expired.
C# and the .NET Platform, Second Edition
Either type faster or increase the amount of time the DataSet will remain in the cache ;-) Wait a few seconds,
by Andrew Troelsen ISBN:1590590554
and click the Refresh button from browser two one more time. Now you should see the new item, given that
Apress © 2003 (1200 pages)
the DataSet in the cache has expired, and the CacheItemRemovedCallback delegate target method has
This comprehensive text starts with a brief overview of the automatically updated the cached DataSet.
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
As you can see, the major benefit of the Cache type is that you can ensure that when a member is removed, you have a chance to respond. In this example, you certainly could avoid using the Cache, and simply have
the Page_Load() event handler always read directly from the Cars database. Nevertheless, the point should
Table of Contents
be clear: The cache allows you to automatically refresh data using .NET delegates.
C# and the .NET Platform, Second Edition
IntroductionNote Unlike the HttpApplicationState type, the Cache class does not support Lock() and Unlock()
Part One - Introducingmethods. IfC#youaneedtheto.NETupdatePlatforminterrelated items, you will need to directly make use of the types
Chapter 1 within- The thePhilosophySystemof.Threading.NET namespace or the C# "lock" keyword.
Chapter 2 - Building C# Applications
SOURCE The CacheState files are included under the Chapter 19 subdirectory.
Part Two - The C# Programming Language
CODE
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
MaintainingC#Sessionand the .NETDataPlatform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
So much for our examination of application-level state data. Next we check out the role of per-user data stores.
Apress © 2003 (1200 pages)
As mentioned earlier, a session is little more than a given user's interaction with a Web application, which is
This comprehensive text starts with a brief overview of the
represented via theC#HttpSessionStatelanguage a d th ntypequickly. Tomovesmaintainto keystatefultechnicalinformationand for a particular user, the HttpApplication-derivedarchitecturaltype andissuesanyforSystem.NET dev.Weblopers.UI.Page. -derived types may access the Session property. The classic example of the need to maintain per-user data would be an online shopping cart. Again, if 10 people all log onto an online store, each individual will maintain a unique set of items that they (may) intend to
Table of Contents purchase.
C# and the .NET Platform, Second Edition
When a new user logs onto your Web application, the .NET runtime will automatically assign the user a unique
Introduction
session ID, which is used to identify the user in question. Each session ID is assigned a custom instance of the
Part One - Introducing C# and the .NET Platform
HttpSessionState type to hold on to user-specific data. Inserting or retrieving session data is syntactically
Chapter 1 - The Philosophy of .NET
identical to manipulating application data, for example:
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter// Add3 /- C#retreiveLanguageaFundamentalssession variable for current user.
Session["DesiredCarColor"] = "Green";
Chapter 4 - Object-Oriented Prog amming with C#
string c = (string) Session["DesiredCarColor"];
Chapter 5 - Exceptions and Object Lifetime Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
The HttpApplication-derived type allows you to intercept the beginning and end of a session via the
Chapter 8 - Advanced C# Type Construction Techniques
Session_Start() and Session_End() event handlers. Within Session_Start(), you can freely create any per-user
Part Three - Programming with .NET Assemblies
data items, while Session_End() allows you to perform any work you may need to do when the user's session
Chapter 9 - Understanding .NET Assemblies has terminated:
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming public class Global : System.Web.HttpApplication
Part Four - Leveraging the .NET Libraries
{
Chapter 12 - Object Serialization and the .NET Remoting Layer
protected void Session_Start(Object sender, EventArgs e)
Chapter 13 - Building a Better Window (Introducing Windows Forms)
{ /* Prep user data here! */}
Chapter 14 - A Better Painting Framework (GDI+)
protected void Session_End(Object sender, EventArgs e)
Chapter 15 - Programming with Windows Forms Controls
{ /* Terminate user data here! */ }
Chapter 16 - The System.IO Namespace
...
Chapter 17 - Data Access with ADO.NET
}
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Like the HttpApplicationState type, the HttpSessionState may hold any System.Object-derived type, including
Chapter 19 - ASP.NET Web Applications
your custom classes. For example, assume you have a new Web application (SessionState) that defines a
Chapter 20 - XML Web Services
helper class named UserShoppingCart:
Index
List of Figures
public class UserShoppingCart
List of Tables
{
public string desiredCar; public string desiredCarColor; public float downPayment; public bool isLeasing;
public DateTime dateOfPickUp; public override string ToString()
{
return string.Format
("Car: {0}<br>Color: {1}<br>$ Down: {2}<br>Lease: {3}<br>Pick-up Date: {4}" desiredCar, desiredCarColor, downPayment, isLeasing, dateOfPickUp.ToShortDateString());
}
}
Within the Session_Start() event handler, you can now assign each user a new instance of the
C# and the .NET Platform, Second Edition
UserShoppingCart class:
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
protected void Session_Start(Object sender, EventArgs e)
This comprehensive text starts with a brief overview of the
{
C# language and then quickly moves to key technical and
Session["UserShoppingCartInfo"] architectural issues for .NET developers.
= new UserShoppingCart();
}
Table of Contents
C# and the .NET Platform, Second Edition
As the user traverses your Web pages, you are able to pluck out the UserShoppingCart instance and fill the
Introduction
fields with user-specific data. For example, assume we have a simple *.aspx page that defines a set of input
Part One - Introducing C# and the .NET Platform
widgets that correspond to each field of the UserShoppingCart type and a Button used to set the values (Figure
Chapter 1 - The Philosophy of .NET
19-5).
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter |
Programming |
Part
Chapter
Chapter
Figure 19-5: The cache application GUI
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
ChapterThe server16 --sideThe SystemClick event.IO Namespacehandler is straightforward (scrape out values from TextBoxes and display the
Chaptershopping17 cart- DatadataAccesson awithLabelADOtype):.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
private void btnSubmit_Click(object sender, System.EventArgs e)
Chapter 19 - ASP.NET Web Applications
{
Chapter //20 -SetXML WebcurrentS rvicesuser prefs.
Index UserShoppingCart u =
(UserShoppingCart)Session["UserShoppingCartInfo"];
u.dateOfPickUp = myCalendar.SelectedDate;
List of Tables
u.desiredCar = txtCarMake.Text; u.desiredCarColor = txtCarColor.Text; u.downPayment = float.Parse(txtDownPayment.Text); u.isLeasing = chkIsLeasing.Checked; lblUserInfo.Text = u.ToString(); Session["UserShoppingCartInfo"] = u;
}
Within Session_End(), you may wish to persist the fields of the UserShoppingCart to a database or whatnot. In any case, if you were to launch two or three instances of your browser of choice, you would find that each user is able to build a custom shopping cart that maps to his or her unique instance of HttpSessionState.
Additional Members of HttpSessionState
The HttpSessionState class defines a number of other members of interest beyond the type indexer. First, the
C# and the .NET Platform, Second Edition
SessionID property will return the current user's unique ID:
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
lblUserID.Text = string.Format("Here is your ID: {0}",
This comprehensive text starts with a brief overview of the
Session.SessionID);
C# language and then quickly moves to key technical and architectural issues for .NET developers.
The Remove() and RemoveAll() method may be used to clear items out of the user's instance of
Table of Contents
HttpSessionState:
C# and the .NET Platform, Second Edition
Introduction
Session.Remove["SomeItemWeDontNeedAnymore"];
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
The HttpSessionState type also defines a set of members that control the expiration policy of the current session. Again, by default each user has 20 minutes of inactivity before the HttpSessionState object is
destroyed. Thus, if a user enters your Web application (and therefore obtains a unique session ID), but does no
Chapter 4 - Object-Oriented Programming with C#
return to the site within 20 minutes, the runtime assumes the user is no longer interested, and destroys all
Chapter 5 - Exceptions and Object Lifetime
session data for that user. You are free to change this default 20-minute expiration value on a user-by-user
Chapter 6 - Interfaces and Collections
basis using the TimeOut property. The most common place to do so is within the scope of your
Chapter 7 - Callback Interfaces, Delegates, and Events
Global.Session_Start() method:
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
protected void Session_Start(Object sender, EventArgs e)
Chapter 9 - Understanding .NET Assemblies
{
Chapter 10 - Processes, AppDomains, Contexts, and Threads
// Each user has 5 minutes of inactivity.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Session.Timeout = 5;
Part Four - Leveraging the .NET Libraries
Session["UserShoppingCartInfo"]
Chapter 12 - Object Serialization and the .NET Remoting Layer
= new UserShoppingCart();
Chapter 13 - Building a Better Window (Introducing Windows Forms)
}
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Note If you do not need to tweak each user's Timeout value, you are able to alter the 20-minute default for
Chapter 17 - Data Access with ADO.NET
all users via the Timeout attribute of the <sessionState> element within the web.config file (examined
Part Five - Web Applications and XML Web Services
at the end of this chapter).
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
The benefit of the Timeout property is that you have the ability to assign specific timeout values discretely for
Chapter 20 - XML Web Services
each user. For example, imagine you have created a Web application that allows users to pay cash for a given Indmembershipx level. You may say that Gold members time out within one hour while Wood members only get 30
Lisecondst of Figures. This possibility begs the question: How can you remember user-specific information (such as the
current membership level) across Web visits? One possible answer is through the user of the HttpCookie type |
|
List of Tables |
|
(speaking of cookies...) |
|
SOURCE |
The SessionState files are included under the Chapter 19 subdirectory. |
CODE |
|
UnderstandingC# andCookiesthe .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
The final state management technique examined here is the act of persisting data within a text file
Apress © 2003 (1200 pages)
(formally called a cookie) on the user's machine. When a user logs onto a given site, the browser checks
This comprehensive text starts with a brief overview of the
to see if the user'sC#machinel nguagehasndathenpreviouslyquicklypersistedmoves tofilek yfortecthenicalURLandin question, and if so, appends the information to thearchitecturaloutgoing HTTPissuesrequestfor .NET. developers.
The receiving server-side Web page could then read the cookie data to create a GUI that may be based
Tableon theof currentContentsuser preferences. I am sure you noticed that when you visit one of your favorite Web sites, it C#somehowand the .justNETknowsPlatform,theSecondsort of Editioncontent you wish to see. For example, when I log onto
http://www.ministryofsound.com, I am automatically shown content that reflects my musical tastes. The
Introduction
reason (in part) has to do with a cookie stored on my computer that contains information regarding the
Part One - Introducing C# and the .NET Platform
type of music I tend to play.
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
The exact location of your cookie files will depend on which browser you happen to be using. For those of
Part Two - The C# Programming Language
us using Microsoft IE, cookies are stored by default under <root>\Documents and
Chapter 3 - C# Language Fundamentals
Settings\<loggedOnUser>\Cookies (Figure 19-6).
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter |
Programming |
Part
Chapter
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 19-6: Cookie data as persisted under Microsoft IE
Chapter 14 - A Better Painting Framework (GDI+)
ChapterThe contents15 - Profgrammigivengcookiewith Wndowsfile will obviouslyForms Controlsvary among URLs; however, keep in mind that they are
Chapterultimately16 text- ThefilesSystem. Thus,.IOcookiesNam sparece a horrible choice when you wish to maintain sensitive information
Chapterabout the17 current- Data Accuserss(suchwith ADOas a.NETcredit card number, password, or whatnot). Even if you take the time to
PartencryptFive the- Webdata,Applia craftyationshackernd XMLcouldWebdecryptSe vicesthe value and use it for purely evil pursuits. In any case, Chaptercookies18do-playASP.aNETroleWebin thePagesdevelopmentand Web Controlsof Web applications, so let's check out how ASP.NET handles
this particular state management technique.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
IndexCreating Cookies
List of Figures
First of all, understand that ASP.NET cookies can be configured to either be persistent or temporary. A
List of Tables
persistent cookie is typically regarded as the classic definition of cookie data, in that the set of name/value pairs are physically saved to the user's hard drive. Temporary cookies (also termed session cookies) contain the same data as a persistent cookie, however, the name/value pairs are never saved to the user's machine, but rather exist only within the HTTP header. Once the user logs off your site, all data contained within the session cookie is destroyed.
The System.Web.HttpCookie type is the class that represents the server side of the cookie data (persistent or temporary). When you wish to create a new cookie, you access the Response.Cookies property. Once the new HttpCookie is inserted into the internal collection, the name/value pairs flow back to the browser within the HTTP header.
To check out cookie behavior firsthand, create a new ASP.NET Web application (CookieStateApp) and create the user interface displayed in Figure 19-7.
ISBN:1590590554
overview of the
technical and
Table
C# and
Part
Chapter
Chapter
Figure 19-7: The UI of the CookiesStateApp
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Within the Button's Click event handler, build a new HttpCookie and insert it into the Cookie collection
Chapter 4 - Object-Oriented Programming with C#
exposed from the HttpRequest.Cookies property. Be very aware that the data will not persist itself to the
Chapter 5 - Exceptions and Object Lifetime
user's hard drive unless you explicitly set an expiration date using the HttpCookie.Expires property. Thus,
Chapter 6 - Interfaces and Collections
the following implementation will create a temporary cookie that is destroyed when the user shuts down
Chapter 7 - Callback Interfaces, Delegates, and Events the browser:
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
private void btnInsertCookie_Click(object sender, System.EventArgs e)
Chapter 9 - Understanding .NET Assemblies
{
Chapter 10 - Processes, AppDomains, Contexts, and Threads
// Make a new (temp) cookie.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
HttpCookie theCookie =
Part Four - Leveraging the .NET Libraries
new HttpCookie(txtCookieName.Text,
Chapter 12 - Object Serialization and the .NET Remoting Layer
txtCookieValue.Text);
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Response.Cookies.Add(theCookie);
Chapter 14 - A Better Painting Framework (GDI+)
}
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
However the following generates a persistent cookie that will expire on March 24, 2004:
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapterprivate18 -voidASP.NETbtnInsertCookieWeb Pages and W bClick(objectControls sender, System.EventArgs e)
{
Chapter 19 - ASP.NET Web Applications
// Make a new (persistent) cookie.
Chapter 20 - XML Web Services
Index HttpCookie theCookie =
List of Figures new HttpCookie(txtCookieName.Text,
List of Tables txtCookieValue.Text);
theCookie.Expires = DateTime.Parse("03/24/2004");
Response.Cookies.Add(theCookie);
}
If you were to run this application and insert some cookie data, the browser automatically persists this data to disk. When you open this text file, you will see something like what is shown in Figure 19-8.
Figure 19-8: The persistent cookie data
Reading Incoming Cookie Data |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Recall that the browser is the entity in charge of accessing persisted cookies when navigating to a
Apress © 2003 (1200 pages)
previously visited page. To interact with the incoming cookie data under ASP.NET, access the
This comprehensive text starts with a brief overview of the
HttpRequest.Cookies property. To illustrate, if you were to update your current UI with the means to obtain
C# language and then quickly moves to key technical and
current cookie dataarchviatecturala Buttonissueswidget,for .NETyou coulddevelopiterates. over each name/value pair and present the
information within a Label widget:
Table of Contents
private void btnShowCookies_Click(object sender, System.EventArgs e)
C# and the .NET Platform, Second Edition
{
Introduction
string cookieData = "";
Part One - Introducing C# and the .NET Platform
foreach(string s in Request.Cookies)
Chapter 1 - The Philosophy of .NET
{
Chapter 2 - Building C# Applications
cookieData +=
Part Two - The C# Programming Language
string.Format("<li><b>Name</b>: {0}, <b>Value</b>: {1}</li>",
Chapter 3 - C# Language Fundamentals
s, Request.Cookies[s].Value);
Chapter }4 - Object-Oriented Programming with C#
Chapter lblCookieData5 - Exceptions and.TextObject=LifetimecookieData;
Chapter} 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
If you now run the application and click your new button, you will find that the cookie data has indeed been
Chapter 9 - Understanding .NET Assemblies sent by your browser (Figure 19-9).
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part |
|
Chapter |
Layer |
Chapter |
Forms) |
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Part |
|
Chapter |
|
Chapter |
|
Chapter |
|
Index |
|
List of |
|
List of |
|
Figure 19-9: Viewing cookie data
So! At this point in the chapter you have examined numerous ways to remember information about your users. As you have seen, view state and application, cache, session, and cookie data are manipulated in more or less the same way (via a class indexer). As you have also seen, the HttpApplication type is often used to intercept and respond to events that occur during your Web application's lifetime. Next up: the role of the web.config file.
SOURCE The CookieStateApp files are included under the Chapter 19 subdirectory.
CODE
ConfiguringC#Yourand theASP.NET.Platform,NET WebS condApplicationEdit on Using web.config
by Andrew Troelsen |
ISBN:1590590554 |
During your examination of .NET assemblies you learned that client applications can leverage an XML-
Apress © 2003 (1200 pages)
based configuration file to instruct the CLR how it should handle binding requests, assembly probing, and
This comprehensive text starts with a brief overview of the
other runtime detailsC# language. The sameandholdsthen trueq icklyformovesASP.NETto keyWebtechnicalapplications,nd with the notable exception that Web-centric configurationarchitecturalfilesissuaresalwaysfor .NETnameddev lopersweb.config (unlike *.exe config files that are named based on the related client executable).
TableWhenofyouContentscreate a new ASP.NET Web app using VS .NET, you will be given a web.config file that resides C#in theandrootthe .ofNETthePlapplication'stform, SecondvirtualEditiondirectory. If you open this file and examine its contents, you find that
its overall structure looks something like the following:
Introduction
Part One - Introducing C# and the .NET Platform
Chapter<?xml1 version="1- The Philosophy.0"ofencoding="utf.NET -8" ?>
Chapter<configuration>2 - Building C# Applications
Part<systemTwo - The.C#web>Programming Language
Chapter<compilation3 - C# Language Fundamentals
defaultLanguage="c#"
Chapter 4 - Object-Oriented Programming with C#
debug="true"/>
Chapter 5 - Exceptions and Object Lifetime
<customErrors
Chapter 6 - Interfaces and Collections
mode="RemoteOnly"/>
Chapter 7 - Callback Interfaces, Delegates, and Events
<authentication mode="Windows" />
Chapter 8 - Advanced C# Type Construction Techniques
<authorization>
Part Three - Programming with .NET Assemblies
<allow users="*" />
Chapter 9 - Understanding .NET Assemblies
</authorization>
Chapter 10 - Processes, AppDomains, Contexts, and Threads
<trace
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming enabled="false"
Part Four - Leveraging the .NET Libraries
requestLimit="10"
Chapter 12 - Object Serialization and the .NET Remoting Layer pageOutput="false"
Chapter 13 - Building a Better Window (Introducing Windows Forms) traceMode="SortByTime"
Chapter 14 - A Better Painting Framework (GDI+) localOnly="true"/>
Chapter 15 - Programming with Windows Forms Controls
<sessionState
Chapter 16 - The System.IO Namespace
mode="InProc"
Chapter 17 -stateConnectionString="tcpip=127Data Access wi h ADO.NET .0.0.1:42424"
Part Five - WebsqlConnectionString="dataApplications d XML Web Servicessource=127.0.0.1;Trusted_Connection=yes"
Chapter 18 -cookieless="false"ASP.NET Web Pages and Web Controls
Chapter 19 -timeout="20"/>ASP.NET Web Applications
<globalization
Chapter 20 - XML Web Services
Index requestEncoding="utf-8"
responseEncoding="utf-8"/>
List of Figures
</system.web>
List of Tables
</configuration>
Like any *.config file, web.config defines the root level <configuration> element. Nested within the root is the <system.web> element, which can contain numerous subelements used to control how your Web application should behave at runtime. If you have a background in classic ASP, the web.config file should make you quite happy, given that you are not limited to using the IIS manager to alter the behavior of your Web application (which typically required rebooting your app). Under ASP.NET, the web.config file can be modified using any text editor. Table 19-4 outlines the role of the subelements that are defined within the web.config file created by VS .NET.
Table 19-4: Select Elements of a web.config File
Element of |
C# and |
|
theMeaning.NET Platform,in LifeSecond Edition |
|
web.config |
by Andrew Troelsen |
ISBN:1590590554 |
||
File |
Apress © 2003 (1200 pages) |
|
||
|
|
|
|
|
<compilation>
Table of Contents
This comprehensive text starts with a brief overview of the
This element is used to enable (or disable) debugging, define the default
C# language and then quickly moves to key technical and
.NET language used by this Web application, and may optionally define architectural issues for .NET developers.
the set of external .NET assemblies that should be automatically referenced (this technique is typically only useful if you are not making use of VS .NET).
|
|
|
|
|
|
|
|
|
C# and the .NET Platform, |
|
|
|
Second Edition |
|
|
||
|
<customErrors> |
|
|
|
Used to tell the runtime exactly how to display errors that occur during |
|
|
|
Introduction |
|
|
|
the functioning of the Web app. |
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Part One - Introducing C# |
|
|
and the .NET Platform |
|
||||
|
|
|
|
|
||||
Chapter<authentication>1 - The Philosophy |
|
|
|
Aofsecurity.NET -related element used to define the authentication mode for this |
|
|
||
|
Chapter 2 |
- Building C# |
|
|
|
ApplicationsWeb application. |
|
|
|
|
|
|
|
|
|||
Part Two - The C# Programming Language |
|
|
||||||
|
<authorization> |
|
|
|
Another security-centric element used to define which users can access |
|
|
|
Chapter 3 |
- C# Language Fundamentals |
|
|
|||||
|
|
|
|
|
|
which resources on the Web server. |
|
|
|
Chapter 4 |
- Object-Oriented |
Programming with C# |
|
|
|||
|
|
|||||||
|
<trace> |
|
|
|
|
Used to enable (or disable) tracing support for this Web application. |
|
|
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
|
||||
|
|
|
|
|
|
|
||
|
Chapter 6 |
- Interfaces and |
|
Collections |
|
|
||
|
<sessionState> |
|
|
|
Used to control how and where session state data will be stored by the |
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
||||
|
|
|
|
|
|
.NET runtime. |
|
|
|
|
|
|
|
|
|
|
|
|
Chapter 8 |
- Advanced C# |
|
|
Type Construction Techniques |
|
||
|
<globalization> |
|
|
|
Used to configure the globalization settings for this Web application. |
|
|
|
Part Three - Programming |
|
|
|
with .NET Assemblies |
|
|
||
|
|
|
||||||
|
|
|
|
|
|
|
|
|
Chapter 9 |
- Understanding .NET Assemblies |
|||||||
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
|||||||
|
A web.config file may contain additional subelements above and beyond the set presented in Table 19-4. |
|||||||
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
A vast majority of these items are security-related, while the remaining items are only useful during
Part Four - Leveraging the .NET Libraries
advanced ASP.NET scenarios such as creating with custom HTTP headers or custom HTTP modules
Chapter 12 - Object Serialization and the .NET Remoting Layer
(not covered here). If you wish to see the complete set of elements that can appear in a web.config file,
Chapter 13 - Building a Better Window (Introducing Windows Forms) look up the topic "ASP.NET Settings Schema" using online Help.
Chapter 14 - A Better Painting Framework (GDI+)
Note ASP.NET security issues are also beyond the scope of this text. If you are interested in learning
Chapter 15 - Programming with Windows Forms Controls
about ASP.NET security, I again point you to .NET Security (Bock, Apress 2002).
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
PartEnablingFive - Web ApplicationsTracing andviaXML<trace>Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
The first aspect of the web.config file we examine is the <trace> sub-element. This XML entity may take
Chapter 19 - ASP.NET Web Applications
any number of attributes to further qualify its behavior, as seen in the following skeleton:
Chapter 20 - XML Web Services
Index
<trace enabled="true|false"
List of Figures
localOnly="true|false"
List of Tables
pageOutput="true|false"
requestLimit="integer"
traceMode="SortByTime|sortByCategory"/>
Table 19-5 hits the highlights of each attribute.
Table 19-5: Attributes of the <trace> Element
|
<trace> |
C# |
|
andMeaningthe .NETinPlatform,Life Second Edition |
|
|
Attribute |
by |
|
Andrew Troelsen |
ISBN:1590590554 |
|
|
|
|
|
|
|
Enabled |
Apress © 2003 (1200 pages) |
|
||
|
|
|
Specifies whether tracing is enabled for an application as a whole (the default |
||
|
|
This comprehensive text starts with a brief overview of the |
|||
|
|
|
|
is false). As you have already seen in the previous chapter, you can |
|
|
|
C# language and then quickly moves to key technical and |
|||
|
|
architecturalselectivelyissuesenablefor .NETtracingdevelopers.for a given *.aspx file using the @Page directive. |
|||
|
|
|
|
|
|
|
localOnly |
|
|
Indicates that the trace information is viewable only on the host Web server |
|
Table of Contents |
|
|
and not by remote clients (the default is true). |
||
|
|
|
|
||
|
|
|
|
C#pageOutputnd the .NET Platform,SpecifiesSecondhowEditiontrace output should be viewed.
Introduction |
Specifies the number of trace requests to store on the server. The default is |
requestLimit |
|
Part One - Introducing |
C# and the .NET Platform |
|
10. If the limit is reached, trace is automatically disabled. |
Chapter 1 - The Philosophy of .NET |
ChaptertraceMode2 - Building C#IndicatesApplicationsthat trace information is displayed in the order it is processed. The Part Two - The C# Programmingdefault is LanguageSortByTime, but can also be configured to sort by category.
Chapter 3 - C# Language Fundamentals
Recall from the previous chapter that individual pages may enable tracing using the <%@Page%>
Chapter 4 - Object-Oriented Programming with C#
directive. However, if you wish to enable tracing for all pages in your Web application, simply update
Chapter 5 - Exceptions and Object Lifetime
<trace> as follows:
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
<trace
Chapter 8 - Advanced C# Type Construction Techniques
enabled="true"
Part Three - Programming with .NET Assemblies
requestLimit="10"
Chapter 9 - Understanding .NET Assemblies
pageOutput="false"
Chapter 10 - Processes, AppDomains, Contexts, and Threads
traceMode="SortByTime"
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
localOnly="true"
Part Four - Leveraging the .NET Libraries
/>
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+) ChapterCustomizing15 - ProgrammingErrorwithOutputWindows FormsviaControls<customErrors>
Chapter 16 - The System.IO Namespace
The <customErrors> element can be used to automatically redirect all errors to a custom set of *.html
Chapter 17 - Data Access with ADO.NET
files. This can be helpful if you wish to build a more user-friendly error page than the default supplied by
Part Five - Web Applications and XML Web Services
the CLR. In its skeleton form, the <customErrors> element looks like the following:
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
<customErrors defaultRedirect="url" mode="On|Off|RemoteOnly">
Chapter 20 - XML Web Services
Index<error statusCode="statuscode" redirect="url"/>
</customErrors>
List of Figures
List of Tables
To illustrate the usefulness of the <customErrors> element, assume your ASP.NET Web application has two *.htm files. The first file (genericError.htm) functions as a catch-all error page. Perhaps this page contains an image of your company logo, a link to e-mail the system administrator, and some sort of apologetic verbiage. The second file (Error404.htm) is a custom error page that should only occur when the runtime detects error number 404 (the dreaded resource not found error). Now, if you want to ensure that all errors are handled by these custom pages, you can update your web.config file as follows:
<customErrors defaultRedirect ="genericError.htm" mode="On">
<error statusCode="404"redirect="Error404.htm"/>
</customErrors>
Note how the root <customErrors> element is used to specify the name of the generic page for all unhandled errors. One attribute that may appear in the opening tag is mode. The default setting is RemoteOnly, which instructs the runtime not to display custom error pages if the HTTP request came from
the same machine as the Web server (quite helpful for developers, who would like to see the details).
C# and the .NET Platform, Second Edition
When you set the mode attribute to "on," this will cause custom errors to be seen from all machines
by Andrew Troelsen ISBN:1590590554
(including your development box). Also note that the <customErrors> element may support any number of
Apress © 2003 (1200 pages)
nested <error> elements to specify which page will be used to handle specific error codes.
This comprehensive text starts with a brief overview of the
To test these customC# languageerror redirects,and henbuildquicklyan *moves.aspx pageto k ythattechnicaldefinesandtwo Button widgets and handle their
architectural issues for .NET developers.
Click events as follows:
private void btnGeneralError_Click(object sender, System.EventArgs e)
Table of Contents
{
C# and the .NET Platform, Second Edition
// This will trigger a general error.
Introduction
throw new Exception("General error...");
Part One - Introducing C# and the .NET Platform
}
Chapter 1 - The Philosophy of .NET
private void btn404Error_Click(object sender, System.EventArgs e)
Chapter 2 - Building C# Applications
{
Part Two - The C# Programming Language
// This will trigger 404 (assuming there is no file named foo.aspx!)
Chapter 3 - C# Language Fundamentals
Response.Redirect("Foo.aspx");
Chapter 4 - Object-Oriented Programming with C#
}
Chapter 5 - Exceptions and Object Lifetime Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Options for Storing State via <sessionState>
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
By far and away the most powerful aspect of a web.config file is the <sessionState> element. By default,
Chapter 9 |
- Understanding .NET Assemblies |
|
ASP.NET will store session state using an in-process *.dll hosted by the ASP.NET worker process |
||
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
|
(aspnet_wp.exe). Like any *.dll, the plus side is that access to the information is as fast as possible. |
||
Chapter 11 |
- Type Reflect on, Late Binding, and Attribute-Based Programming |
|
However, on the downside, if this AppDomain crashes (for whatever reason) all of the user's state data is |
||
Part Four - Leveraging |
.NET Libraries |
|
destroyed. Furthermore, when you store state data as an in-process *.dll, you cannot interact with a |
||
Chapter 12 |
- Object Serialization and the .NET Remoting Layer |
networked Web farm. By default, the <sessionState> element of your web.config file looks like this:
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
<sessionState
Chapter 15 - Programming with Windows Forms Controls mode="InProc"
Chapter 16 - ThestateConnectionString="tcpip=127Sys em.IO Namespace .0.0.1:42424"
Chapter 17 - DatasqlConnectionString="dataAccess with ADO.NET source=127.0.0.1;Trusted_Connection=yes"
Part Five - Web Applicationscookieless="false"and XML W b Services
Chapter 18 - ASPtimeout="20".NET Web Pages and Web Controls
Chapter/>19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
This default mode of storage works just fine if your Web application is hosted by a single Web server. However, under ASP.NET, you can instruct the runtime to host the session state *.dll in a surrogate process named the ASP.NET Session State Server (aspnet_state.exe). When you do so, you are able to offload the *.dll from aspnet_wp.exe into a unique *.exe. The first step in doing so is to start the aspnet_state.exe Windows service. To do so at the command line, simply type:
net start aspnet_state
Alternatively, you can also start aspnet_state.exe using the Services applet accessed from the Administrative Tools folder of the Control Panel (Figure 19-10).
ISBN:1590590554
overview of the
technical and
Table
C# and
Figure 19-10: The Services applet
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
The key benefit of this approach is that you can configure aspnet_state.exe to start automatically when the machine boots up using the Properties window. In any case, once the session state server is running, alter the <sessionState> element of your web.config file as follows:
Chapter 3 |
- C# Language Fundamentals |
Chapter 4 |
- Object-Oriented Programming with C# |
Chapter<sessionState5 - Exceptions and Object Lifetime |
|
Chapter 6 |
- Interfacesmode="StateServer"and Collections |
Chapter 7 |
stateConnectionString="tcpip=127.0.0.1:42424" |
- Callback Interfaces, Delegates, and Events |
|
Chapter 8 |
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" |
- Advanced C# Type Construction Techniques |
|
|
cookieless="false" |
Part Three - Programming with .NET Assemblies |
|
|
timeout="20" |
Chapter 9 |
- Understanding .NET Assemblies |
/> |
|
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
PartHere,Fourthe- Leveragingmode attributethe .hasNETbeenLibrarisetsto StateServer. That's it! At this point the CLR will host session- Chapcentricer 12within- ObjectaspnetSerialization_state.exe.andIn thistheway,.NET ifRemotingthe AppDomainLayer hosting the Web application crashes, the
session data is preserved. Also notice that the <sessionState> element can also support a
Chapter 13 - Building a Better Wind w (Introducing Windows Forms)
stateConnectionString attribute. The default TCPIP address value (127.0.0.1) points to the local machine.
Chapter 14 - A Better Painting Framework (GDI+)
If you would rather have the .NET runtime use the aspnet_state.exe service located on another networked
Chapter 15 - Programming with Windows Forms Controls
machine (again, think Web-farms), you are free to update this value.
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Finally, if you require the highest degree of isolation and durability for your Web application, you may
Part Five - Web Applications and XML Web Services
choose to have the runtime store all your session state data within MS SQL Server. The appropriate
Chapter 18 - ASP.NET Web Pages and Web Controls update to the web.config file is simple:
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
<sessionState
Index |
mode="SQLServer" |
List of Figures stateConnectionString="tcpip=127.0.0.1:42424" |
|
List of Tables |
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" |
|
|
|
cookieless="false" |
/> |
timeout="20" |
|
However, before you attempt to run the associated Web application, you need to ensure that the target machine (specified by the sqlConnectionString attribute) has been properly configured. When you install the .NET SDK (or VS .NET), you will be provided with two files named InstallSqlState.sql and UninstallSqlState.sql, located by default under <drive>:\<%windir%>\Microsoft.NET\Framework\<version>. On the target machine, you must run the InstallSqlState.sql file using a tool such as the SQL Server Query Analyzer (which ships with MS SQL Server).
Once this SQL script has executed, you will find a new SQL Server database has been created (ASPState), which contains a number of stored procedures called by the ASP.NET runtime, as well as a set of tables used to store the session data itself (also, the tempdb database has been updated with a set
of tables for swapping purposes). As you would guess, configuring your Web application to store session
C# and the .NET Platform, Second Edition
data within SQL Server is the slowest of all possible options. The benefit is that user-data is as durable as
by Andrew Troelsen ISBN:1590590554 possible (even if the Web server is rebooted).
Apress © 2003 (1200 pages)
Note If you makeThis comprehensiveuse of the ASPtext.NETstartsSessionwith aStatebri fServeroverviewor ofSQLtheServer to store your session data, you mustC#makelanguagesureandthathenanyquicklycustommovestypestoplacedkey technicalin the HttpSessionStateand object have been
architectural issues for .NET developers.
marked with the [serializable] attribute! Given this requirement, it is always best practice to always apply the [serializable] attribute to any custom type that will be placed in the
HttpSessionState type.
Table of Contents
C# and the .NET Platform, Second Edition
Custom Web Settings via <appSettings>
Introduction
Part One - Introducing C# and the .NET Platform
The final aspect of the web.config file I wish to examine here is the process of storing (and retrieving)
Chapter 1 - The Philosophy of .NET
custom data. One common use of this technique is to store ADO.NET connection strings. In this way, if
Chapter 2 - Building C# Applications
you need to alter the connection credentials, you don't have to update or recompile your *.aspx files.
Part Two - The C# Programming Language
Rather, your pages can read the custom XML data at runtime. The first step in doing so is to add a new
Chapter 3 - C# Language Fundamentals
<appSettings> element in your project's web.config file. This element has two attributes (key and value)
Chapter 4 - Object-Oriented Programming with C#
that will be used to identify the name and value of the data point. For example:
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
<appSettings>
Chapter 7 - Callback Interfaces, Delegates, and Events
<add key = "appConStr"
Chapter 8 - Advanced C# Type Construction Techniques
value = "server=localhost;uid=sa;pwd=;database=Cars"/>
Part Three - Programming with .NET Assemblies
</appSettings>
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterProgrammatically,11 - Type Reflwection,can accessLate Binding,this valueand usingAttributethe-BasedAppSettingsProgrammingproperty of the
PartSystemFour.Configuration- Leveraging the.ConfigurationSettings.NET Libraries type. For example:
Chapter 12 |
- Object Serialization and the .NET Remoting Layer |
Chapter 13 |
- Bu l ing Better Window (Introducing Windows Forms) |
private |
void btnReadAppSettings Click(object sender, System.EventArgs e) |
Chapter{ 14 - A Better Painting Framework (GDI+)
Chapter string15 - ProgrammingconStr with= Windows Forms Controls
ConfigurationSettings.AppSettings["appConStr"];
Chapter 16 - The System.IO Namespace
lblConStringValue.Text = conStr;
Chapter 17 - Data Access with ADO.NET
}
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
ConfigurationC# andInheritancet .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Last but not least is configuration inheritance. As you learned in the previous chapter, a Web application
Apress © 2003 (1200 pages)
can be defined as the set of all files contained within a root directory and any optional subdirectories. All
This comprehensive text starts with a brief overview of the
our example appsC#inlanguagethis and theandpreviousthen quicklychaptermoveshaveto keyexistedtechnicalon a andsingle root directory managed by IIS
(with the optionalarchitectural\bin folder). issuesHowever,for .largeNET developers-scale Web. applications tend to define numerous subdirectories off the root, each of which contains some set of related files. Like a traditional desktop application, this is typically done for the benefit of us mere humans, as a hierarchal structure can make a
Table of Contents
massive set of files more understandable.
C# and the .NET Platform, Second Edition
When you have an ASP.NET Web application that consists of optional subdirectories off the root, you may
Introduction
be surprised to discover that each subdirectory may have its own web.config file! By doing so, you allow
Part One - Introducing C# and the .NET Platform
each subdirectory to override the settings of a parent directory. If the subdirectory in question does not
Chapter 1 - The Philosophy of .NET
supply a custom web.config file, it will inherit the settings of the next available web.config file up the
Chapter 2 - Building C# Applications
directory structure. Thus, as bizarre as it sounds, it is possible to inject an OO-look and feel to a raw
Part Two - The C# Programming Language
directory structure. Figure 19-11 illustrates the concept.
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Chapter |
Programming |
Figure 19-11: Configuration inheritance
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
ChapterOf course,13 -althoughBuilding aASPBetter.NETWindowdoes allow(Introducingyou to defineWindowsnumerousForms) web.config files for a single Web app,
Chapteryou are14not- requiredA Bett Paintingto do soFramework. In great(GDI+)many cases, your Web applications function just fine using
Chapternothing15other- Programmingthan the webwith.configWindowsfile locatedForms inControlsthe root directory of the IIS virtual directory.
Chapter 16 - The System.IO Namespace
That wraps up our examination of ASP.NET. At this point, you should have the tools you need to build Web
Chapter 17 - Data Access with ADO.NET
applications under the .NET platform. To wrap up our voyage, the final chapter examines a related Web-
Part Five - Web Applications and XML Web Services
centric topic: XML Web Services.
Chapter 18 - ASP.NET Web Pages and Web Controls Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Summary C# and the .NET Platform, Second Edition
by Andrew Troelsen ISBN:1590590554
In this chapter, you rounded out your knowledge of ASP.NET by examining how to leverage the
Apress © 2003 (1200 pages)
HttpApplication type. As you have seen, this type provides a number of default event handlers that allow
This comprehensive text starts with a brief overview of the you to intercept variousC# languageapplicationnd then-andquicklysessionmoves-leveltoeventskey technical. and
architectural issues for .NET developers.
The bulk of this chapter was spent examining a number of state management techniques. Recall that view state is used to automatically repopulate the values of HTML widgets between post backs to a specific
Tablepageof. Next,Contentsyou checked out the distinction between application-level and session-level data, cookie C#management,d the .NETandPlatform,the ASPecond.NETEditionapplication cache. Finally, this chapter examined a number of elements
that may be contained in the web.config file.
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Chapter C#20:andXMLthe .NETWebPlatform,Servicescond Edition
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages) |
|
Overview This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
Back in Chapter 12architectural, you wereissuesintroducedfor .NETto thed velopers.NET Remoting. layer. As you have seen, this technology is a managed replacement for classic DCOM, which allows any number of .NET-aware machines to exchange information across the wire. While this is all well and good, one possible limitation of this
Tableapproachf Contentsto building a distributed system is the fact that all networked machines must have the .NET
C#Frameworknd the .NETinstalledPlatform,. Therefore,Sec nd Editionuntil the .NET platform is completely ported to other non-Windows-based
Introductionoperating systems, it would be next to impossible to pass a CLR type to a .NET-naïve machine.
Part One - Introducing C# and the .NET Platform
In contrast to .NET Remoting, XML Web services offer a more agnostic alternative to distributed
Chapter 1 - The Philosophy of .NET
application development. Simply put, an XML Web service is a unit of code hosted by a Web server (such
Chapter 2 - Building C# Applications
as Microsoft IIS) that can be invoked using vanilla-flavored HTTP. Furthermore, if the invoked method returns a value to the caller, it is encoded as simple XML. As you would guess, using neutral technologies
such as HTTP and XML data representation, XML Web services offer an unprecedented level of operating
Chapter 4 - Object-Oriented Programming with C# system, platform, and language interoperability.
Chapter 5 - Exceptions and Object Lifetime
ChapterIn this chapter,6 - Interfacesyou learndhowCollectionsto build XML Web services using the .NET platform, which as you will see is
Chpainfullypter 7 simple- Callback. In addition,Interfaces,thisDelegates,chapter examinesand Eventsa number of surrounding XML Web service-centric
Chaptertopics such8 - asAdvancedthe SimpleC# TypeObjectConstructionAccess ProtocolTechniques(SOAP) and the Web Service Description Language
Part(WSDL)Three. Once- Programmingyou havewithcome.NETto understandAss mblies the composition of an XML Web service, this chapter Chapterillustrates9 how- Understanding.NET client.NETapplicationAssembliesmay interact with an XML Web service using a related proxy type.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .RoleNET Platform,of XMLSecondWebEditionServices
by Andrew Troelsen |
ISBN:1590590554 |
From the highest level, one can simply define an XML Web service as a unit of code that can be invoked
Apress © 2003 (1200 pages)
via HTTP requests. Unlike a traditional Web application however, XML Web services are not (necessarily)
This comprehensive text starts with a brief overview of the
used to emit HTMLC#backl nguageto a browserand th nforquicklydisplaymovespurposesto key.technicalRather, anandXML Web service exposes the same sort of functionalityarchitecturalfoundissuesin aforstandard.NET developers.NET code. library, in that it defines computational objects that execute a unit of work for the consumer (e.g., crunch some numbers, read information from a data source, or whatnot), return a result (if necessary), and wait for the next request.
Table of Contents
C#Givenand thise .definition,NET Platform,XMLSecondWeb servicesEdition may seem to be little more than yet another remoting technology.
However, let's think this one through a bit. Historically speaking, accessing remote types required platform-
Introduction
specific (and often language-specific) protocols. For example, DCOM clients communicate with remote
Part One - Introducing C# and the .NET Platform
COM types using tightly coupled ORPC calls. CORBA and EJB (Enterprise Java Beans) applications also
Chapter 1 - The Philosophy of .NET
require a specific protocol, and EJB requires a specific language (Java). The basic problem at hand is not
Chapter 2 - Building C# Applications
the technology themselves, but the fact that each is locked into a specific (often proprietary) wire protocol.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Another fundamental problem with these remoting architectures is that they each require the sender and
Chapter 4 - Object-Oriented Programming with C#
receiver to understand the same underlying type system. For example, a DCOM client must be able to
Chapter 5 - Exceptions and Object Lifetime
manipulate COM interfaces, while EJB clients must understand Java agents. Even in the case of .NET
Chapter 6 - Interfaces and Collections
Remoting, it is assumed that the client and remote servers are both .NET-aware entities. Given this, it
Chapter 7 - Callback Interfaces,clientD legates, andclueEv nts
should be obvious that a Java has little what to do with a .NET System.Collections.ArrayList
Chapterobject.8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
XML Web services provide a way for unrelated platforms, operating systems, and programming languages
Chapter 9 - Understanding .NET Assemblies
to exchange information in harmony. As you will see, rather than forcing the caller to understand a specific
Chapter 10 - Processes, AppDomains, Contexts, and Threads
type system (.NET, COM, J2EE, or whatnot), information is passed between systems via XML data
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
representation. Therefore, as long as the client is able to parse a well-formed XML document, it will be
Part Four - Leveraging the .NET Libraries
able to map the underlying XML elements into platform and/or language specific types.
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
In addition to a neutral type system, Web services allow you to invoke methods and properties of a remote
Chapter 14 - A Better Painting Framework (GDI+)
object using standard HTTP requests. To be sure, of all the protocols in existence today, HTTP is the one
Chapter 15 - Programming withplatformsWindows Forms Controls
specific wire protocol that all can agree on (after all, HTTP is the backbone of the World Wide
ChapterWeb). 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
In a nutshell, XML Web services offer a way to let the Web provide information that can be pieced together
Part Five - Web Applications and XML Web Services
to build a platformand language-agnostic distributed system.
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
ChapterXML20Web- XMLServiceW b ServicesConsumers
Index
One aspect of XML Web services that might not be readily understood is the fact that an XML Web service
List of Figures
consumer does not need to be a traditional Web client. As you will see, console-based and Windows
List of Tables
Forms-based clients can use a Web service just as easily. In each case, the XML Web service consumer indirectly interacts with the distant Web service through an intervening proxy type.
The proxy (which is described in detail later in the chapter) looks and feels like the real remote type and exposes the same set of members. Under the hood, however, the proxy's implementation code forwards requests to the XML Web service using standard HTTP. The proxy also maps the incoming stream of XML back into .NET-specific data types (or whatever type system is required by the consumer application). Figure 20-1 illustrates the fundamental nature of XML Web services (do note that the scenarios presented here are not all-encompassing).
ISBN:1590590554
of the
and
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
ChapterFigure5 - 20Exceptions-1: XML andWebObjectservicesLifetimein action
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Again, notice how each consumer application makes use of a language-specific proxy type, which (a)
Chapter 8 - Advanced C# Type Construction Techniques
forwards calls to the remote Web service via HTTP, and (b) maps the incoming XML stream back into
Part Three - Programming with .NET Assemblies
platform-specific data types. Also note that if the XML Web service client happens to be a Web application
Chapter 9 - Understanding .NET Assemblies
(such as an ASP.NET *.aspx file), the Web page itself is the actual client of the Web service. This page
Chapter 10 - Processes, AppDomains, Contexts, and Threads
may (or may not) make use the incoming XML data stream to emit an HTML-based UI to the requesting
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
browser.
Part Four - Leveraging the .NET Libraries
Note Technically, Internet Explorer 5.0 (and higher) is capable of being the direct client of an XML
Chapter 12 - Object Serialization and the .NET Remoting Layer
Web service using WebService behaviors. If you are interested in checking this out, read the
Chapter 13 - Building a Better Window (Introducing Windows Forms)
article "About the WebService Behavior" online at http://msdn.microsoft.com.
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The BuildingC# Blocksand the .NETofPlantform,XMLSecondWebEditionService
by Andrew Troelsen |
ISBN:1590590554 |
XML Web services built using the .NET platform are typically hosted by IIS using a unique virtual directory
Apress © 2003 (1200 pages)
(much like a standard ASP.NET Web application). However, in addition to the managed code that
This comprehensive text starts with a brief overview of the
constitutes the exportedC# languagefunctionality,and thenanquicklyXML Webmovesserviceto keyrequirest chnicalsomeand supporting infrastructure. Specifically, an XMLarchitecturalWeb serviceissuesinvolvesf r .NETthedevelfollowingpers. key services:
A discovery service (so clients can resolve the location of the XML Web service)
Table of Contents
A description service (so clients know what the XML Web service can do)
C# and the .NET Platform, Second Edition
Introduction
A transport protocol (to pass the information between the client and the XML Web service)
Part One - Introducing C# and the .NET Platform
ChapterWe'll examine1 - ThedetailsPhilo ophybehindof each.NET core requirement throughout this chapter. However, to get into the
Chaptproperr 2frame- Buildingof mind,C#ponderApplicationsthe following overview of each supporting technology.
Part Two - The C# Programming Language
ChaptPreviewingr 3 - C# LanguageXMLFundamentalsWeb Service Discovery
Chapter 4 - Object-Oriented Programming with C#
ChapterBefore5a client- Exceptiocan insvokeand theObjectfunctionalityLifetime of a Web service, it must first know of its existence and location.
ChapterNow, if6you- areInterfacesthe individualand Collections(or company) who is building both the client and XML Web service, the Chapterdiscovery7 phase- Callbackis quiteInterfaces,simple,Delegates,given thatandyouEventsalready know the location of the Web service in question.
However, what if you wish to share the functionality of your Web service with the world at large?
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
To do this, you have the option of registering your Web service with a UDDI (Universal Description, Discovery and Integration) server. Clients may submit a request to a UDDI catalog to find a list of all Web
services that match some search criteria (e.g., "Find me all Web services having to do with financial
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
calculations"). Once you have identified a specific XML Web server from the list returned via the UDDI
Part Four - Leveraging the .NET Libraries
query, you are then able to investigate its overall functionality. If you like, consider UDDI to be the yellow
Chapter 12 - Object Serialization and the .NET Remoting Layer pages of XML Web services.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterIn addition14 -toAUDDI,Better anPaintingXML WebFrameworkservice(GDI+)built using .NET can be exposed to the masses using DISCO, Chapterwhich is15a -ratherProgrammingforced acronymwith WindowsstandingFormsfor DiscoveryControls of Web Services. Using a *.disco (or *.vsdisco)
file, you are able to advertise the set of XML Web services that are located at a specific URL. For the most
Chapter 16 - The System.IO Namespace
part, *.disco/*.vsdisco files are consumed by Visual Studio .NET during the design of a Web service client.
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Understand, however, that by default, DISCO functionality is disabled, given the potential security risk of
Chapter 18 - ASP.NET Web Pages and Web Controls
exposing IIS to report the set of all exposed Web services to any interested individual (in fact, the
Chapter 19 - ASP.NET Web Applications
autogenerated *.vsdisco files which used to appear when using VS .NET 2002 are no longer
Chapter 20 - XML Web Services
autogenerated). Given these issues, I do not comment on DISCO services for the remainder of this text.
Index
List ofNoteFiguresIf you wish to activate DISCO support for a given Web server, look up the Microsoft Knowledge
Base article Q307303 on http://support.microsoft.com.
List of Tables
Previewing XML Web Service Description
Once a client knows the location of a given XML Web service, the client in question must fully understand the exposed functionality. For example, the client must know that there is a method named Foo() that takes three parameters of type {string, bool, int} and returns a custom type named Bar before it can invoke it. As you may be thinking, this is a job for a platform-, language-, and operating system-neutral metalanguage. Specifically speaking, the XML-based grammar used to describe a Web service is termed the Web Service Description Language, or simply WSDL.
The role of WSDL is to describe the functionality of a Web service in a neutral format. In many ways, WSDL is the Web service equivalent of COM-centric type libraries or .NET-centric metadata (recall the Ctrl+M keystroke of ildasm.exe). The distinguishing mark with regard to WSDL syntax is that it describes an XML Web service using the big-string known as XML. Thus, as long as your client can parse a string, it will be able to understand the functionality of a remote Web service.
For the most part, the underlying WSDL can be safely ignored (although the .NET base class libraries do
C# and the .NET Platform, Second Edition
provide a specific namespace devoted to processing WSDL documents). As you will see, the primary
by Andrew Troelsen ISBN:1590590554
consumers of WSDL contracts are proxy generation tools. For example, the wsdl.exe command line utility
Apress © 2003 (1200 pages)
(as well as the VS .NET Add Web Reference wizard) will generate a C# proxy class based on the data
This comprehensive text starts with a brief overview of the contained in a WSDL document.
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Previewing the Transport Protocol
TableOnceoftheContclienttshas created a proxy type to communicate with the remote XML Web service, it is now able
to call the exposed Web methods. As mentioned, HTTP is the wire protocol that transmits this data.
C# and t .NET Platform, Second Edition
Specifically however, you can use HTTP GET, HTTP POST, or SOAP to move information between
Introduction
consumers and Web services.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
By and large, SOAP will be your first choice, for as you will see, SOAP messages can contain XML
Chapter 2 - Building C# Applications
descriptions of very complex types (including your custom types as well as serializable types within the
Part Two - The C# Programming Language
.NET libraries). On the other hand, if you make use of the HTTP GET or HTTP POST protocols, you are
Chapter 3 - C# Language Fundamentals
restricted to a more limited set of core data types. As you would hope, the .NET platform supports all three
Chapter 4 - Object-Oriented Programming with C# modes of activation.
Chapter 5 - Exceptions and Object Lifetime Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The .NET XMLC# andWebthe .NETServicePlatform,NamespacesSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
Now that you have an understanding of the role of XML Web services and the surrounding technologies,
Apress © 2003 (1200 pages)
we can get down to the business of building such a creature using the .NET platform. As you would
This comprehensive text starts with a brief overview of the
imagine, the baseC#classlanguagelibrariesanddefinethen quicklya numbermovesof namespacesto key technicalthatandallow you interact with each Web service-centric technologyarchitectural(Tableissues20for-1).NET developers.
Table 20-1: XML Web Service-Centric Namespaces
Table of Contents |
|
Meaning in Life |
||
C#Weband theService.NET Platform,-CentricSecond Edition |
|
|||
IntroductionNamespace |
|
|
||
|
|
|
|
|
Part One - Introducing C# and the .NET Platform |
||||
|
System.Web.Services |
This surprisingly small namespace contains the minimal |
||
Chapter 1 - The Philosophy of .NET |
and complete set of types needed to build a Web |
|||
Chapter 2 - Building C# Applications |
||||
service, such as the almighty WebMethodAttribute type. |
||||
|
|
|
||
Part Two - The C# Programming Language |
|
|
||
|
|
|||
ChapterSystem.Web.Services.Configuration3 - C# Language Fundamentals |
|
These types allow you to configure the runtime behavior |
||
|
Chapter 4 - Object-Oriented Programming |
|
of an ASP.NET XML Web service. |
|
|
|
with C# |
||
|
|
|||
|
Chapter 5 - Exceptions and Object Lifetime |
|
These types allow you to programmatically interact with |
|
|
System.Web.Services.Description |
|
||
|
Chapter 6 - Interfaces and Collections |
|
the WSDL document that describes a given Web service. |
|
|
|
|
|
|
|
Chapter 7 - Callback Interfaces, Delegates, |
|
and Events |
|
|
System.Web.Services.Discovery |
|
These types allow a Web consumer to programmatically |
|
|
Chapter 8 - Advanced C# Type Construction |
|
Techniques |
|
|
|
|
discover the Web services installed on a given machine. |
|
Part Three - Programming with .NET Assemblies |
||||
|
|
|
|
ChapterSystem9 .Web- Understanding.Services.Protocols.NET A sembliesThis namespace defines a number of types that
Chapter 10 - Processes, AppDomains, Contexts,representand Threadsthe atoms of the various XML Web service
Chapter 11 - Type Reflection, Late Binding, andwireAttributeprotocols-Based(HTTPProgrammingGET, HTTP POST, and SOAP).
Part Four - Leveraging the .NET Libraries
ChapterNote12 All- ObjectXML WebS rializationservice-andcentriche namespaces.NET RemotingareLayercontained within the System.Web.Services.dll
Chapter 13 assembly- Building.a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
ExaminingC#theandSystemthe .NET Platform,.Web.ServicesS cond EditionNamespace
by Andrew Troelsen |
ISBN:1590590554 |
Despite the rich functionality provided by the .NET Web services namespaces, a vast majority of your
Apress © 2003 (1200 pages)
applications will only require you to directly interact with the types defined in System.Web.Services. As you
This comprehensive text starts with a brief overview of the
can see from TableC# 20lang-2uage, the andnumberth nofquicklytypesmovesis quitetosmallkey technical(which isanda good thing).
architectural issues for .NET developers.
Table 20-2: Members of the System.Web.Services Namespace
|
|
|
|
|
|
|
TableSystem.Web.Servicesof Contents |
|
Meaning in Life |
|
|
||
C#Typeand the .NET Platform, Second |
|
Edition |
|
|
||
|
|
|
|
|
|
|
|
Introduction |
|
Adding the [WebMethod] attribute to a method or property in a |
|
|
|
|
WebMethodAttribute |
|
|
|
||
Part One - Introducing C# and the |
|
.NET Platform |
|
|
||
Chapter 1 |
- The Philosophy of .NET |
|
Web service class type marks the member as invokable via |
|
|
|
|
HTTP. |
|
|
|||
|
Chapter 2 |
- Building C# Applications |
|
|
|
|
|
|
|
|
|
||
PartWebServiceTwo - The C# Programming LanguageDefines the (optional) base class for XML Web services built |
|
|
||||
Chapter 3 |
- C# Language Fundamentalsusing .NET. If you choose to derive from this base type, your |
|
|
|||
Chapter 4 |
|
|
XML Web service will have the ability to retain stateful |
|
|
|
- Object-Oriented Programming with C# |
|
|
||||
|
|
|
|
information. |
|
|
|
Chapter 5 |
- Exceptions and Object |
|
Lifetime |
|
|
|
||||||
|
Chapter 6 |
- Interfaces and Collections |
|
|
||
|
WebServiceAttribute |
|
The [WebService] attribute may be used to add information to a |
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
||
|
|
|
|
Web service, such as a string describing its functionality and |
|
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
||
|
|
|
|
underlying XML namespace. |
|
|
|
|
|
|
|
|
|
Part Three - Programming with .NET |
|
Assemblies |
|
|
||
|
WebServiceBindingAttribute |
|
Declares the binding protocol a given Web service method is |
|
|
|
Chapter 9 |
- Understanding .NET |
|
Assemblies |
|
|
|
|
|
|
|
implementing (HTTP GET, HTTP POST, or SOAP). |
|
|
|
Chapter 10 |
- Processes, AppDomains, |
|
Contexts, and Threads |
|
|
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
Part Four - Leveraging the .NET Libraries
The remaining namespaces are typically only of direct use to you if you are interested in manually
Chapter 12 - Object Serialization and the .NET Remoting Layer
interacting with a WSDL document, UDDI services, or manipulating the underlying wire protocols. While Chapteryou will13see- BuildingrelevantaaspectsBetter Windowof these(Introducingadditional namespacesWindows Forms)where necessary, consult online Help for
Chaptercomplete14 details- A Betterof thePaintingremainingFrameworknamespaces(GDI+) if you so choose.
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Building anC#XMLand theWeb.NETServicePlatform, Secondin theEditionRaw
by Andrew Troelsen |
ISBN:1590590554 |
Like any .NET application, XML Web services can be developed manually, without the use of an integrated
Apress © 2003 (1200 pages)
development environment such as VS .NET. To illustrate, let's get to know the types within the
This comprehensive text starts with a brief overview of the
System.Web.ServicesC# languagenamespaceand thenby buildingquickly movesa Webtoservicekey technicalby handand. Using your text editor of choice, create a new file architecturalnamed HelloWorldWSissues for ..NETasmxdevelopersand enter. the following type definition (by convention, *.asmx is the extension used to mark .NET Web service files):
Table of Contents
<%@ WebService Language="C#" Class="HelloWS.HelloClass" %>
C# and the .NET Platform, Second Edition
namespace HelloWS
Introduction
{
Part One - Introducing C# and the .NET Platform
public class HelloClass
Chapter{1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
[System.Web.Services.WebMethod]
Part Two - The C# Programming Language
public string HelloWorld()
Chapter 3 - C# Language Fundamentals
{ return "Hello!"; }
Chapter}4 - Object-Oriented Programming with C#
Chapter} 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
For the most part, this *.asmx file looks like any other C# namespace definition. The first noticeable
Part Three - Programming with .NET Assemblies
difference is the use of the <%@WebService%> directive, which at minimum must specify the name of the
Chapter 9 - Understanding .NET Assemblies
managed language used to build the contained class definition and the name of the class type itself. In addition to the Language and Class attributes, the <%@WebService%> directive may also take Debug attribute (to inform the ASP.NET compiler to emit debugging symbols) and an optional CodeBehind value
(which has an identical role to that of the same value used for *.aspx files). Here, we have avoided the use
Chapter 12 - Object Serialization and the .NET Remoting Layer
of a code behind file and embedded all required logic directly within HelloWorldWS.asmx.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterNote14 The- A Betteronly otherPaintingdirectiveFrameworkthat may(GDI+)appear in an *.asmx file is <%@Assembly%>, used to mark the
Chapter 15 names- Programmingof externalwithassembliesWindows Forms(or fileControlsnames) that will be used during the ASP.NET compilation Chapter 16 cycle- The. SystemThe additional.IO Namespace*.aspx directives examined in the previous chapter (such as
<%@Import%>) are not valid. Thus, if you would rather not use fully qualified names in your
Chapter 17 - Data Access with ADO.NET
code base (as seen here), simply use the C# "using" keyword.
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
In addition to the <%@WebService%> directive, the only other distinguishing characteristic of our *.asmx
Chapter 19 - ASP.NET Web Applications
file is the use of the [WebMethod] attribute, which informs the ASP.NET runtime that this method is
Chapter 20 - XML Web Services reachable via incoming HTTP requests.
Index
List of Figures
Creating the IIS Virtual Directory
List of Tables
Now that you have created the HelloWS Web service, the next step is to host this file within a virtual directory. Using the information presented in Chapter 18, create a new virtual directory named HelloWS that maps to the physical folder containing the HelloWorldWS.asmx file (for example, C:\HelloWS).
Testing YourC# andXMLtheWeb.NET Platform,ServiceS cond Edition
by Andrew Troelsen |
ISBN:1590590554 |
When you install the .NET Framework, ASP.NET is configured to automatically display a browser-based
Apress © 2003 (1200 pages)
UI to test installed Web services. When an HTTP request comes in that maps to a given *.asxm file, the
This comprehensive text starts with a brief overview of the
ASP.NET runtimeC#makeslanguageuseandof athenfile namedquickly DefaultWsdlHelpGeneratormoves to key t chnical and .aspx to create an HTML display that allows you toarchitecturalinvoke the Webissuesmethodsfor .NETatdevelopersa given URL. (and yes, if you really want to, you can alter the code within this file to suit your needs...edit with care). To illustrate this makeshift client, open your browser of choice and navigate to the HelloWorldWS.asmx file:
Table of Contents
http://localhost/HelloWS/HelloWorldWS.asmx
C# and the .NET Platform, Second Edition
Introduction
At this point, you are presented with a list of all Web methods exposed from this URL (Figure 20-2).
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 20-2: Viewing the functionality of the HelloWorldWS Web service
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
If you click the HelloWorld link, you will be passed to another page that allows you to invoke the
Chapter 12 - Object Serialization and the .NET Remoting Layer
[WebMethod] in question. Once you invoke your Web method, you will not be returned a literal .NET-
Chapter 13 - Building a Better Window (Introducing Windows Forms)
centric System.String, but rather the XML data representation of the textual data returned from the
Chapter 14 - A Better Painting Framework (GDI+)
HelloWorld() Web method (Figure 20-3).
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter
Part
Chapter
Chapter
Chapter
Index
List of
List of Tables
Figure 20-3: Web method return values are expressed in terms of XML.
Although the ASP.NET runtime will dynamically generate an HTML front end to test your Web service, you may wonder what is involved in creating a real client (such as a Windows Forms application). Given that Web methods emit return values via XML, you may fear that you will be required to manually open an HTTP channel and parse the incoming XML tokens back into .NET data types. While you most certainly are free to do so (using types within various .NET namespaces), both.NET SDK and VS .NET provide tools that automate this process. We'll check out client-side functionality later in this chapter.
Viewing the WSDL Contract
As mentioned earlier in this chapter, WSDL is a metalanguage that describes how Web methods can be invoked using the HTTP GET, HTTP POST, and SOAP wire protocols. Notice that when you test a Web services using the autogenerated HTML-based UI, you see a link at the very top of your service's home page named "Service Description." If you click this link, the request is appended with the token "?WSDL." When the ASP.NET runtime receives a request for an *.asmx file tagged with this suffix, it will automatically
return the underlying WSDL that describes each Web method.
C# and the .NET Platform, Second Edition
Once you click thisbylink,AndrewyouTroelsenmay be alarmed with the verbose ISBN:1590590554nature of WSDL. At this point don't concern yourself with the formatApress ©of2003the(1200generatedpages) WSDL document. For the time being, just understand that WSDL describes how WebThismethodscomprehensivecan betextinvokedstartsusingwith aeachbriefofoverviewthe currentof heXML Web service wire protocols.
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Viewing the Compiled .NET Assembly
As you have just seen, when you deploy your *.asmx files, you are not required to manually compile the
Table of Contents
code into a .NET *.dll assembly. Rather, when the Web service is first requested, the ASP.NET runtime
C# and the .NET Platform, Second Edition
compiles the *.dll file dynamically. Recall from Chapter 18 that ASP.NET stores compiled *.dlls under the
Introduction
<drive>:\<%windir%>\Microsoft.NET\ Framework\<version>\Temporary ASP.NET Files\<Autogenerated folder names> subdirectory. Like a compiled ASP.NET Web application, this *.dll can be loaded into
ildasm.exe for further exploration (Figure 20-4).
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter |
|
Chapter |
with C# |
Chapter |
|
Chapter |
|
Chapter |
and Events |
Chapter |
Techniques |
Part |
|
Chapter |
|
Chapter |
and Threads |
ChapterFigure11 - 20Type-4:Reflection,Viewing theLatecompiledBinding,.NETand Attributeassembly-Based Programming
Part Four - Leveraging the .NET Libraries
Given that we did not deploy a precompiled assembly for the current example, the ASP.NET compiler
Chapter 12 - Object Serialization and the .NET Remoting Layer
generated a unique name for the resulting assembly automatically (mine happens to be cgy-xflg.dll). Had
Chapter 13 - Building a Better Window (Introducing Windows Forms)
we precompiled our code into a more human-readable assembly (such as HelloWorldWS.dll) and
Chapter 14 - A Better Painting Framework (GDI+)
deployed this *.dll to a \bin sub-directory under the hosting virtual directory, we would find the shadow copy
Chapter 15 - Programming with Windows Forms Controls would sport an identical name.
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Acfactess with ADO.NET
In addition to the that the autogenerated *.dll has no semantic relationship to the name of the original Part*.asmxFivefile,- WebanotherApplicationsissue isandtheXMLfact Webthat anyServicesand all syntactic errors in the *.asmx file are discovered at Chapterruntime18when- ASPthe.NETASPWeb.NETPagescompilerand WebkicksControlsin. Had we precompiled the *.asmx file into a .NET assembly,
Chapterwe would19 be- ASPable.NETto squashWeb Applicationsout any and all typos at compile time.
Chapter 20 - XML Web Services
The good news is, when you make use of VS .NET to build your XML Web services, you will always
Index
receive a precompiled assembly (placed under the IIS \bin directory) that is named according to your
List of Figures
project settings. Given these benefits, I will make use of VS .NET for the remainder of this chapter.
List of Tables
SOURCE The HelloWorldWS.asmx file is included under the Chapter 20 subdirectory.
CODE
Building anC#XMLand theWeb.NETServicePlatform, SecondUsingEditionVisual Studio .NET
by Andrew Troelsen |
ISBN:1590590554 |
Now that you have created an XML Web service by hand, let's see how VS .NET helps get you up and
Apress © 2003 (1200 pages)
running. Fire up Visual Studio .NET and create a new C# XML Web service project named CalcWebService
This comprehensive text starts with a brief overview of the (Figure 20-5). C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter 8 - Advanced C# Type Construction Techniques
Figure 20-5: Creating a new VS .NET XML Web Service project
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Like an ASP.NET application, VS .NET automatically creates a new virtual directory under IIS to host your
Chapter 10 - Processes, AppDomains, Contexts, and Threads
XML Web service and stores your solution file (*.sln) under the My Documents\ Visual Studio Projects
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
subdirectory.
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
The Global.asax and Web.config files serve the same purpose as (and look identical to) an ASP.NET
Chapter 13 - Building a Better Window (Introducing Windows Forms)
application. As you recall from Chapter 19, the Global.asax file allows you to respond to global-level events
Chapter 14 - A Better Painting Framework (GDI+)
while web.config allows you to declaratively configure the behavior of your new XML Web service. In addition,
Chapter 15 - Programming with Windows Forms Controls
VS .NET has created a *.asmx and *.asmx.cs code behind file to which you are able to implement the exposed
Chapter 16 - The System.IO Namespace
functionality. Finally, like any .NET application created with VS .NET, you are also provided with the
Chapter 17 - Data Access with ADO.NET
AssemblyInfo.cs file that documents any assembly-level attributes.
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
The Code Behind File (*.asmx.cs)
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
When you create a new VS .NET XML Web service project, you will be presented with a design-time
Index
component tray that may be used to hold any and all components used by the *.asmx file (such as ADO.NET Listdataof components)Figures . To view the code behind this design-time template, simply click the "Click here to switch to
Listviewof code"Tableslink to switch to view code link on the designer. Once you do, you will find the following class definition (including a commented-out HelloWorld() Web method, removed for clarity):
public class Service1 : System.Web.Services.WebService
{
public Service1(){ InitializeComponent(); } private IContainer components = null; private void InitializeComponent() { }
protected override void Dispose(bool disposing)
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
}
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
The only real pointApressof interest© 2003 is(1200thepages)fact that you derive from a new base class: WebService. You examine the
members definedThisby thiscomprehensivetype in just texta momentstarts .withForanow,briefjustoverviewunderstandof the that .NET XML Web services have theoption of derivingC# languagefrom thisandbasethenclassquicklytype.movesIn fact,toifkeyyoutechnicalcommentandout the overridden Dispose() method
architectural issues for .NET developers.
and derive directly from System.Object, the Web service still functions correctly, as shown here:
// I'm still a Web service!
Table of Contents
public class Service1 // : System.Web.Services.WebService
C# and the .NET Platform, Second Edition
Introduction{ |
|
} |
|
Part Onepublic- IntroducingService1()C# and the{.NETInitializeComponent();Platform |
|||
... |
|
|
|
Chapter 1 |
- The Philosophy of .NET |
|
|
private void InitializeComponent() { } |
|
||
Chapter 2 |
- Building C# Applications |
|
|
// protected override void Dispose(bool disposing) {...} |
|||
Part Two - The C# Programming Language |
|
|
|
} |
- C# Language Fundamentals |
|
|
Chapter 3 |
|
|
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
|
ChapterAdding6 - SomeInterfacesFunctionalityand Collections |
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
Rename your initial class type to CalcWS and your initial *.asmx file to CalcWS.asmx. Next, define four Web |
|||
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
methods that allow the outside world to add, subtract, multiply, and divide two integers: |
|||
Part Three - Programming with .NET Assemblies |
|
|
|
Chapter 9 |
- Understanding .NET Assemblies |
|
|
public class CalcWS : System.Web.Services.WebService |
|||
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
|
|
{ |
- Type Reflection, Late Binding, and Attribute-Based Programming |
||
Chapter 11 |
|||
public CalcWS() { InitializeComponent(); } |
|
||
Part Four - Leveraging the .NET Libraries |
|
|
|
... |
- Object Serialization and the .NET Remoting Layer |
|
|
Chapter 12 |
|
||
[WebMethod] |
|
|
|
Chapter 13 |
- Building a Better Window (Introducing Windows Forms) |
|
|
public int Add(int x, int y){ return x + y; } |
|||
Chapter 14 |
- A Better Painting Framework (GDI+) |
|
|
[WebMethod] |
|
|
|
Chapter 15 |
- Programming with Windows Forms Controls |
return x - y; } |
|
public int Subtract(int x, int y){ |
|||
Chapter 16 |
- The System.IO Namespace |
|
|
[WebMethod] |
return x * y; } |
||
Chapter 17 |
- Data Access wi h ADO.NET |
||
public int Multiply(int x, int y){ |
|||
Part Five[WebMethod]- Applications and XML Web Services |
|
|
|
Chapter public18 - ASP.NETintWebDividPages(inta d Webx, Cointrolsy) |
|
|
|
Chapter {19 |
- ASP.NET Web Applications |
|
|
Chapter 20 |
- XML//WebTo Servicesaccommodate all wire protocols, simply return 0 |
Index |
// (rather than a DivideByZeroException type, which is SOAP-specific). |
List of Figures |
if(y == 0) |
List of Tables |
return 0; |
|
else |
} |
return x / y; |
|
|
} |
|
Invoking the CalcWS Web Methods
Testing CalcWS is identical to the process of testing the previous HelloWS XML Web service (using VS .NET, you may run or debug the Web service directly within the IDE). Do note that when you are testing a Web method that requires parameters, the autogenerated HTML UI accounts for each argument (Figure 20-6).
Edition
ISBN:1590590554
a brief overview of the to key technical and
.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter 5 - Exceptions and Object Lifetime
Figure 20-6: Invoking the Add() Web method
Chapter 6 |
- Interfaces and Collections |
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
Chapter 8 |
- Advanced C# Type Construction Techniques |
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .SystemNET Platform,.WebSecond.ServicesEdition .WebService Base Class
by Andrew Troelsen |
ISBN:1590590554 |
As seen during the development of the HelloWS project, .NET Web services are free to derive directly
Apress © 2003 (1200 pages)
from System.Object. However, by default, Web services developed using Visual Studio .NET automatically
This comprehensive text starts with a brief overview of the
derive from the SystemC# language.Web.Serviceand th .nWebServicequickly movesbaseto keyclasstechnical. This typeandequips your .NET XML Web service to leveragearctheitecturalsame issuescore functionalityfor .NET developersused by. full blown ASP.NET Web apps (Table 20-3).
Table 20-3: Key Members of the System.Web.Services.WebService Type
|
|
|
|
|
|
Table of Contents |
|
Meaning in Life |
|
||
C#Propertyand the .NETofPlatform, Second Edition |
|
|
|||
IntroductionSystem.Web.Services.WebService |
|
|
|
||
|
|
|
|
|
|
Part One - Introducing C# and the .NET Platform |
|
Provides access to the HttpApplicationState type |
|
||
|
Application |
|
|
||
|
Chapter 1 |
- The Philosophy of .NET |
|
|
|
|
|
|
|
||
|
ChapterContext2 |
- Building C# Applications |
|
Provides access to the HttpContext type (which |
|
Part Two - The C# Programming Language |
|
gives you access to the incoming HTTP request |
|
||
Chapter 3 |
- C# Language Fundamentals |
|
and outgoing HTTP response via the Request |
|
|
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
and Response properties) |
|
|
|
|
|
|
|
|
Chapter 5 |
- Exceptions and Object Lifetime |
|
Provides access to the HttpServerUtility type |
|
|
Server |
|
|
|
|
|
Chapter 6 |
- Interfaces and Collections |
|
|
|
|
|
Provides access to the HttpSessionState type for |
|
||
|
Session |
|
|
|
|
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
||
|
|
|
|
the current session |
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
||
Part Three - Programming with .NET Assemblies |
|
|
|
||
Chapter 9 |
- Understanding .NET Assemblies |
|
|
|
|
|
As you will see, if you wish to build a stateful Web service, you are required to derive from |
||||
Chapter 10 |
- Processes, AppDomains, Contexts, and Threads |
||||
|
System.Web.Services.WebService, given that this type defines the Application and Session properties. |
||||
Chapter 11 |
- Type Reflection, Late Binding, and Attribute-Based Programming |
The Context property and Server properties also provide access to the HttpContext and HttpServerUtility
Part Four - Leveraging the .NET Libraries
types, which allow you to interact with the raw request and response streams (among other things).
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .[WebMethod]NET Platform, SecondAttributeEdit on
by Andrew Troelsen |
ISBN:1590590554 |
As noted, the [WebMethod] attribute must be applied to each public method you wish to expose to the
Apress © 2003 (1200 pages)
outside world through HTTP. Like most attributes, the WebMethodAttribute type may take a number of
This comprehensive text starts with a brief overview of the
optional constructorC# parameterslanguage and. Tablethen quickly20-4 listsmovesthetocorek ypropertiestechnical andof the WebMethodAttribute type.
architectural issues for .NET developers.
Table 20-4: Key Members of the WebMethodAttribute Type
|
|
|
|
|
|
TableWebServiceAttributeof Contents |
|
Meaning in Life |
|
||
C#Propertyand the .NET Platform, Second |
|
Edition |
|
||
|
|
|
|
|
|
|
Introduction |
|
Used to add a friendly text description of your Web method. |
|
|
|
Description |
|
|
||
Part One - Introducing C# and the |
|
.NET Platform |
|
||
|
|
||||
ChapterEnableSession1 - The Philosophy of .NETBy default, this property is set to true, which configures this |
|
||||
Chapter 2 - Building C# Applicationsmethod to maintain session state. You may disable this behavior if |
|
||||
Part Two - The C# Programming Languageyou set it to false. |
|
||||
|
|
|
|
|
|
|
Chapter 3 - C# Language Fundamentals |
|
|||
|
MessageName |
|
This property can be used to configure how a Web method is |
|
|
|
Chapter 4 |
- Object-Oriented Programming with C# |
|
||
|
|
|
|
represented in terms of WSDL (typically to avoid name clashes). |
|
|
Chapter 5 - Exceptions and Object |
Lifetime |
|
||
|
TransactionOption |
|
Web methods can function as the root of a COM+ style |
|
|
Chapter 6 |
- Interfaces and Collections |
|
|||
Chapter 7 |
|
|
transaction. This property may be assigned any value from the |
|
|
- Callback Interfaces, Delegates, and Events |
|
||||
Chapter 8 |
|
|
System.EnterpriseServices.TransactionOption enumeration (which |
|
|
- Advanced C# Type Construction Techniques |
|
will require you to set a reference to the
Part Three - Programming with .NET Assemblies
System.EnterpriseServices.dll assembly).
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartDocumentingFour - L veraging thea Web.NET LibrariesMethod via the Description Property
Chapter 12 - Object Serialization and the .NET Remoting Layer
The Description property of the WebMethodAttribute type allows you to describe the functionality of a
Chapter 13 - Building a Better Window (Introducing Windows Forms)
particular Web method. To illustrate, update each of your Web methods with a friendly help string. For
Chapter 14 - A Better Painting Framework (GDI+) example:
Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
[WebMethod(Description = "Yet another way to add numbers!")]
Chapter 17 - Data Access with ADO.NET
public int Add(int x, int y){ return x + y; }
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
If you compile and test once again, you see something like Figure 20-7.
Chapter 20 - XML Web Services
Index
List of
List of
Figure 20-7: Documenting your Web methods
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Under the hood, when you set the Description property, the WSDL contract is updated with a new
Apress © 2003 (1200 pages)
<documentation> element, which can be viewed via the Service Description link of your Web service's
This comprehensive text starts with a brief overview of the home page: C# language and then quickly moves to key technical and
architectural issues for .NET developers.
<operation name="Add">
<documentation>Yet another way to add numbers!</documentation>
Table of Contents
<input message="s0:AddSoapIn" />
C# and the .NET Platform, Second Edition
<output message="s0:AddSoapOut" />
Introduction
</operation>
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChapterAs you2would- Buildingguess,C#it wouldApplicationsbe completely possible to build a custom utility that reads the value
PartcontainedTwo - ThewithinC# theProgramming<documentation>L nguageelement (for example, an XML Web service-centric object browser).
ChapterIn most3cases- C#however,LanguagethisFundamvaluentawillsbe used by the makeshift browser-based client.
Chapter 4 - Object-Oriented Programming with C#
ChapterAvoiding5 - ExceptionsWSDLandNameObject LifetimeClashes via the MessageName Property
Chapter 6 - Interfaces and Collections
ChapterThe MessageName7 - Callback Interfaces,property ofDelegates,the Systemand.WebEvents.Services.WebMethod type is of special interest. To Chapterillustrate8 its- usefulness,Advanced C#assumeType ConstyouructionWeb calculatorTechniquesnow defines an over-loaded version of Add() which
PartoperatesThr on- Programmingtwo floats: with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter[WebMethod(Description10 - Proces es, A pD mains,= "AddContexts,2 integersand Threads.")]
Chapterpublic11int- TypeAddReflec(intion,x,LateintBinding,y){ andreturnAtt ibutex -+Basedy; Programming}
Part[WebMethod(DescriptionFour - Leveraging the .NET Libraries= "Add 2 floats.")]
Chapterpublic12float- ObjectAddSeria(floatizationx,andfloatthe .NETy){RemotingreturnLayer x + y; }
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
If you recompile your updated class, you will be happy to find you are error-free. However, when you
Chapter 15 - Programming with Windows Forms Controls
request access to the Web service, you find the following error displayed in the makeshift browser client:
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
System.Exception: Both Single Add(Single, Single) and Int32 Add(Int32, Int32)
Part Five - Web Applications and XML Web Services
use the message name 'Add'.
Chapter 18 - ASP.NET Web Pages and Web Controls Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
One requirement of WSDL is that each <soap:operation soapAction> element (which is used to define the
List of Figures
name of a given Web method) must be uniquely named. However, the default behavior of the ASP.NET
ListWSDLof Tablesgenerator is to generate the <soap:operation soapAction> name exactly as it appears in the .NET assembly metadata definition (which is why you ended up with two Web methods named Add().)
To resolve the name clash, you can either rename your method (e.g., AddFloats()) or use the MessageName property to establish a unique name within the WSDL document, as shown here:
[WebMethod(Description = "Add 2 integers.")] public int Add(int x, int y){ return x + y; }
[WebMethod(Description = "Add 2 floats.", MessageName = "AddFloats")] public float Add(float x, float y){ return x + y; }
With this, you can see that each WSDL description is now unique:
<operation name="Add">
<documentation>Add 2 floats.</documentation>
<input name="AddFloats" message="s0:AddFloatsSoapIn" />
C# and the .NET Platform, Second Edition
<output name="AddFloats" message="s0:AddFloatsSoapOut" />
</operation> by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages) |
|
<operation name="Add"> |
|
This comprehensive text starts with a brief overview of the
<documentation>Yet another way to add numbers!</documentation>
C# language and then quickly moves to key technical and
<input message="s0:AddSoapIn" /> architectural issues for .NET developers.
<output message="s0:AddSoapOut" />
</operation>
Table of Contents
C# and the .NET Platform, Second Edition
As you will see a bit later in this chapter, the client-side proxy type transparently maps these unique WSDL
Introduction
names back into true overloaded Add() methods.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Building Stateful Web Services via the EnableSession Property
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
As you recall from Chapter 19, the inherited Application and Session properties allow an ASP.NET Web
Chapter 3 - C# Language Fundamentals
application to maintain stateful data. Web services provide the exact same functionality via the
Chapter 4 - Object-Oriented Programming with C#
System.Web.Services.WebService base class. For example, assume your CalcWebService maintains an
Chapter 5 - Exceptions and Object Lifetime
application-level variable (and is thus available to each session) that holds the value of PI, as shown here:
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
public class CalcWebService: System.Web.Services.WebService
Chapter 8 - Advanced C# Type Construction Techniques
{
Part Three - Programming with .NET Assemblies
// This Web method provides access to an app level variable
Chapter 9 - Understanding .NET Assemblies
// named SimplePI.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
[WebMethod(Description = "Get app variable")]
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming public float GetSimplePI()
Part Four{- Leveragireturng(float)the .NET LibrariesApplication["SimplePI"]; }
Chapter ...12 - Object Serialization and the .NET Remoting Layer
Chapter} 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
The initial value of the SimplePI application variable could be established with the Application_Start() event
Chapter 17 - Data Access with ADO.NET
handler defined in the Global.asax.cs file (recall that the Global class type defines numerous application
Part Five - Web Applications and XML Web Services
and session-level event handlers):
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
public class Global : System.Web.HttpApplication
Chapter 20 - XML Web Services
{
Index
...
List of Figures
protected void Application_Start(Object sender, EventArgs e)
List of Tables
{
Application["SimplePI"] = 3.14F;
}
}
In addition to maintaining application-wide variables, you may also make use of the HttpSessionState type (via the inherited Session property) to maintain session-centric information. For the sake of illustration, update the Global.Session_Start() method to assign a random number to each user who is logged on:
public class Global : System.Web.HttpApplication
{
...
protected void Session_Start(Object sender, EventArgs e)
{
// To prove session state data is available from a Web service,
// simply assign a random number to each user.
C# and the .NET Platform, Second Edition
Random r = new Random();
by Andrew Troelsen ISBN:1590590554
Session["SessionRandomNumber"] = r.Next(1000);
}Apress © 2003 (1200 pages)
}This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Now, create a new Web method that returns the user's randomly assigned value:
Table of Contents
[WebMethod(EnableSession = true,
C# and the .NET Platform, Second Edition
Description = "Get your random number!")]
Introduction
public int GetMyRandomNumber()
Part One - Introducing C# and the .NET Platform
{ return (int)Session["SessionRandomNumber"]; }
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Note that the [WebMethod] attribute has explicitly set the EnableSession property to true. This step is not
Chapter 3 - C# Language Fundamentals
optional, given that by default, each Web method has session state disabled. If you were now to launch Chaptertwo or three4 - Objectbrowsers-Oriented(to generateProgrammingset ofwithsessionC# IDs), you would find that each logged-on user is
returned a unique numerical token. For example, client A may receive the following XML: |
|
Chapter 5 - Exceptions and Object Lifetime |
|
Chapter 6 - Interfaces and Collections |
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
<?xml version="1.0" encoding="utf-8" ?> |
|
Chapter 8 |
- Advanced C# Type Cons ruc ion Techniques |
<int xmlns="http://www.intertech-inc.com/WebServers">931</int> |
|
Part Three - Programming with .NET Assemblies |
|
Chapter 9 |
- Understanding .NET Assemblies |
while client B may find the value 472:
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part<?xmlFour version="1- Leveraging the.0".NETencoding="utfLibraries -8" ?>
Chapter<int xmlns="http://www12 - Object Serialization.andintertechhe .NET Remoting-inc.com/WebServers">Layer 472</int>
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Configuring Session State via web.config
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Finally, do be aware that the web.config file may be updated to configure how state is configured for your
Part Five - Web Applications and XML Web Services
XML Web service using the <sessionState> element (described in the previous chapter).
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
<sessionState
Chapter 20 - XML Web Services
mode="InProc"
Index
stateConnectionString="tcpip=127.0.0.1:42424"
List of Figures
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
List of Tables
cookieless="false"
timeout="20"
/>
UnderstandingC# andthet .[WebService]NET Platform, SecondAttributeEdition
by Andrew Troelsen |
ISBN:1590590554 |
In addition to the [WebMethod] attribute, you are also able to qualify the functionality of the Web service
Apress © 2003 (1200 pages)
itself using the [WebService] attribute. This type defines a few optional properties of interest, the first of
This comprehensive text starts with a brief overview of the which is NamespaceC# language. and then quickly moves to key technical and
architectural issues for .NET developers.
The WebServiceAttribute.Namespace property can be used to establish the name of the default XML namespace to use within the WSDL document. In a nutshell, XML namespaces are used to scope custom
TableXMLofelementsContentswithin a specific group (just like .NET namespaces). By default, the ASP.NET runtime will
assign a dummy XML namespace of http://tempuri.org, which can be seen at the home page for a
C# and the .NET Platform, Second Edition
given *.asmx file (Figure 20-8).
Introduction
Part One - Introducing C# and the .NET Platform
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Figure 20-8: The dummy value for your XML namespace is http—//tempuri.org.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Before you publish your Web service to the world at large, you should supply a proper namespace that
Part Four - Leveraging the .NET Libraries
reflects the point of origin. Thus, if you wish to describe and qualify an XML namespace, you can make
Chapter 12 - Object Serialization and the .NET Remoting Layer
use of the [WebService] attribute as follows (note that the [WebService] attribute also supports the
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Description property):
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
[WebService(Description = "The Amazing Calculator Web Service!",
Chapter 16 - The System.IO Namespace
Namespace ="http://www.intertech-inc.com/WebServices")]
Chapter 17 - Data Access with ADO.NET
public class CalcWS : System.Web.Services.WebService
Part Five - Web Applications and XML Web Services
{... }
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
If you rerun the application, you will find that the warning to replace tempuri.org is no longer present.
Chapter 20 - XML Web Services
Furthermore, if you click the Service Description link to view the underlying WSDL, you will find that the
Index
TargetNamespace attribute has now been updated with your custom URI.
List of Figures
List of Tables
The final property of the WebServiceAttribute type is Name, which is used to establish the name of the XML Web service exposed to the outside world. By default, the external name of a Web service is identical to the name of the class type itself. However, if you wish to de-couple the .NET class name from the underlying WSDL name, you can update the [WebService] attribute as follows:
[WebService(Description = "The Amazing Calculator Web Service!",
Namespace ="http://www.intertech-inc.com/WebServices",
Name = "MyWayCoolWebCalculator")]
public class CalcWS : System.Web.Services.WebService
{
...
}
SOURCE
CODE
C# Theand filesthe .forNETthePlatform,CalcWebServiceSecond Editionproject can be found under the Chapter 20
by Andrew Tr elsen |
ISBN:1590590554 |
subdirectory. |
|
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Exploring theC# andWebthe .ServiceNET Platform,DescriptionSe ond EditionLanguage (WSDL)
by Andrew Troelsen ISBN:1590590554
Now that you have seen two XML Web services in action, let's examine some additional syntactic details of
Apr ss © 2003 (1200 pages)
WSDL. Recall that WSDL is an XML-based grammar that describes how external clients can interact with
This comprehensive text starts with a brief overview of the
the Web methodsC#atlanguagegiven URL,and thenusingquicklyeach movesof the supportedto key chnicalwire protocolsand . In many ways a WSDL document can bearchitecturalviewed as aissuescontractfor .betweenNET d velopersthe Web. service client and the Web service itself. To this end, it is yet another metalanguage. Specifically, WSDL is used to describe the following characteristics for each exposed Web method:
Table of Contents
C#andThethename.NET Platform,of the XMLSecondWeb methodEdition
Introduction
The number of, type of, and ordering of parameters (if any)
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
The type of return value (if any)
Chapter 2 - Building C# Applications
Part TwoThe-HTTPThe C#GET,ProgrammingHTTP POST,Languageand SOAP calling conventions
Chapter 3 - C# Language Fundamentals
In most cases, WSDL documents are generated automatically by the hosting Web server. Recall that
Chapter 4 - Object-Oriented Programming with C#
when you append the "?WSDL" suffix to a URL that points to an *.asmx file, IIS will emit the WSDL
Chapter 5 - Exceptions and Object Lifetime document for the specified XML Web service:
Chapter 6 - Interfaces and Collections
Chttp://localhost/SomeWS/theWSapter 7 - Callback Interfac s, Delegates, and Events
.asmx?WSDL
Chapter 8 - Advanced C# Type Construction Techniques
As you would expect, this approach is typically all you need to concern yourself with. However, it is also
Part Three - Programming with .NET Assemblies
possible to begin a Web service project by building the WSDL document by hand. This approach really
Chapter 9 - Understanding .NET Assemblies
highlights the fact that WSDL documents function as a contract between the sender and receiver, and is
Chapter 10 - Processes, AppDomains, Contexts, and Threads
reminiscent of the process taken by C++ COM developers ("first define the IDL... then implement the
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
coclass"). Once this WSDL document has been created, it may be passed into the wsdl.exe utility to build
Part Four - Leveraging the .NET Libraries
a client-side proxy file as well as the shell of the server-side *.asmx file.
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
As you would imagine, taking this approach would require you to have a very intimate view of the WSDL
Chapter 14 - A Better Painting Framework (GDI+)
grammar, which is beyond the scope of this chapter. Nevertheless, you'll see numerous examples of
Chapter 15 - Programming with Windows Forms Controls
working with the wsdl.exe command line tool in the sections that follow. Before that point, however, let's Chapget toerknow16 - Tthe basicSy temstructure.IO Namespaceof valid WSDL document.
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The Basic FormatC# and theof.NETa Platform,WSDL SecDocumentnd Edition
by Andrew Troelsen |
ISBN:1590590554 |
A valid WSDL document is opened and closed using the root <definitions> element. The opening tag typically
Apress © 2003 (1200 pages)
defines various xmlns attributes. These qualify the XML namespaces that define various subelements. At
This comprehensive text starts with a brief overview of the
minimum, the <definitions>C# languageelementand thenwillquicklyspecifymovesthe namespaceto key te hnicalwhereandthe WSDL elements themselves are defined (http://schemasarchitectural.issuesxmlsoapfor .NETorg/wsdldevelopers). To. be useful, the opening <definitions> tag will also speci numerous XML namespaces that define simple data WSDL types, XML schema, SOAP elements, as well as th target namespace. For example:
Table of Contents
C# and the .NET Platform, Second Edition
<?xml version="1.0" encoding="utf-8"?>
Introduction
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
Part One - Introducing C# and the .NET Platform
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
Chapter 1 - The Philosophy of .NET
xmlns:s="http://www.w3.org/2001/XMLSchema"
Chapter 2 - Building C# Applications
xmlns:s0="http://tempuri.org/"
Part Two - The C# Programming Language
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
Chapter 3 - C# Language Fundamentals
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
ChtargetNamespace="http://tempuripter 4 - Object-Oriented Programming with C#
.org/"
Chapterxmlns="http://schemas5 - Exceptions and Object.xmlsoapLifetime.org/wsdl/">
Chapt</definitions>r 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Within the scope of the root element, you will find five possible subelements. Thus, a bare-bones WSDL
Part Three - Programming with .NET Assemblies
document would look something like the following:
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
<?xml version="1.0" encoding="utf-8"?>
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
<definitions ...>
Part Four - Leveraging the .NET Libraries
<type>
Chapter 12 - Object Serialization and the .NET Remoting Layer
<!-- List of types exposed from WS ->
Chapter 13 - Building a Better Window (Introducing Windows Forms)
</type>
Chapter 14 - A Better Painting Framework (GDI+)
<message>
Chapter 15 - Programming with Windows Forms Controls
<!-- Format of the messages ->
Chapter 16 - The System.IO Namespace
</ message>
Chapter 17 - Data Access with ADO.NET
<portType>
Part Five - Web Applications and XML Web Services
<!-- Port information ->
Chapter 18 - ASP.NET Web Pages and Web Controls
</portType>
Chapter 19 - ASP.NET Web Applications
<binding>
Chapter 20 - XML Web Services
<!-- Binding information ->
Index </binding>
List of Figur<service>s
List of Tables <!-- Information about the XML Web Service itself ->
</service>
</definitions>
As you would guess, each of these subelements will contain additional elements and attributes to further describe the intended functionality. Let's check out the key nodes in turn.
The <type> Element
First, we have the <type> element, which contains descriptions of any and all custom types exposed from the Web service. You will learn exactly how to expose custom .NET data types via a given Web method a bit later i this chapter. However, for the sake of illustration, assume you have defined a Web method that takes as a parameter a structure named Foo. The Foo structure defines two fields named theInt and theString:
public struct Foo
{
C# and the .NET Platform, Second Edition int theInt;
by Andrew Troelsen |
ISBN:1590590554 |
string theString; |
|
}Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
The underlying <type> element would describe Foo as a <complexType> as follows:
<s:complexType name="Foo">
Table of Contents
<s:sequence>
C# and the .NET Platform, Second Edition
<s:element minOccurs="1" maxOccurs="1" name="theInt" type="s:int" />
Introduction
<s:element minOccurs="0" maxOccurs="1" name="theString" type="s:string"
Part One - Introducing C# and the .NET Platform
</s:sequence>
Chapter 1 - The Philosophy of .NET
</s:complexType>
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
In addition to complex type descriptions, the <type> block also lists any core WSDL data types defined by the Chttp://wwwapter 4 - Object.w3.-Orientedorg/2001/XMLSchemaProgramming withXMLC# namespace that have been exposed from the set of Web
Chaptermethods5 (string,- Exceptionsint, float,nddouble,Object Lifetimeand so forth).
Chapter 6 - Interfaces and Collections
ChaptTher<message>7 - Callback Interfaces,ElementDelegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
PartTheThree<message>- Programmingelementwithis used.NETtoAssembliesdefine the format of the request and response exchange for a given Web
Chaptermethod9. Given- U derstthatandisingle.NETWebAsservicembli allows multiple messages to be transmitted between the sender and
Chapterreceiver,10it-isProcessepermissible, AppDomaifor singles, Contexts,WSDL documentand Threadsto define multiple <message> elements.
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Regardless of how many <message> elements are defined within a WSDL document, they tend to occur in pai
Part Four - Leveraging the .NET Libraries
The first definition represents the input-centric format of the message, while the second defines the output-cent
Chapter 12 - Object Serialization and the .NET Remoting Layer
format of the same message. For example, if you define a single Web method named MyMethod(), which take
Chapter 13 - Building a Better Window (Introducing Windows Forms)
no parameters and returns nothing, the SOAP <message> pair could be constructed as follows:
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
<message name="MyMethodSoapIn">
Chapter 16 - The System.IO Namespace
<part name="parameters" element="s0:MyMethod" />
Chapter 17 - Data Access with ADO.NET
</message>
Part Five - Web Applications and XML Web Services
<message name="MyMethodSoapOut">
Chapter 18 - ASP.NET Web Pages and Web Controls
<part name="parameters" element="s0:MyMethodResponse" />
Chapter 19 - ASP.NET Web Applications
</message>
Chapter 20 - XML Web Services
Index
ListIn reality,of Figures<message> elements are not all that useful in and of themselves. However, these message definition
ListareofreferencedTables by other aspects of the WSDL document.
The <portType> Element
The <portType> element defines the characteristics of the various correspondences that can occur between th client and server, each of which is represented by an <operation> subelement. As you would guess, the most common operation is the classic HTTP request/response cycle. Additional operations do exist, however. For example, the one-way operation allows a client to send a message to a given Web server but does not receive response (sort of a fire-and-forget method invocation). The solicit/response operation allows the server to issue request while the client responds (which is the exact opposite of the request/response operation).
To illustrate the format of a possible <operation> subelement, here is the WSDL definition for a traditional request/response operation for the MyMethod() Web method described previously:
<portType>
<operation name="MyMethod">
<input message="s0:MyMethodSoapIn" />
C# and the .NET Platform, Second Edition |
|
<output message="s0:MyMethodSoapOut" /> |
|
by Andrew Troelsen |
ISBN:1590590554 |
</operation> |
|
</portType> Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Note how the <input> and <output> elements make reference to the related message name defined within the <message> element.
Table of Contents
The <binding> Element
C# and the .NET Platform, Second Edition
Introduction
This element specifies the exact format of the HTTP GET, HTTP POST, and SOAP exchanges. By far and awa this is the most verbose of all the subelements contained in the <definition> root. For example, here is the <binding> element definition that describes how a caller may interact with the MyMethod() Web method using
Chapter 2 - Building C# Applications
SOAP:
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
<binding name="SomeWSSoap" type="s0:SomeWSSoap">
Chapter 4 - Object-Oriented Programming with C#
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"
Chapter 5 - Exceptions and Object Lifetime
<operation name="MyMethod">
Chapter 6 - Interfaces and Collections
<soap:operation soapAction=
Chapter 7 - Callback Interfaces, Delegates, and Events
"http://tempuri.org/MyMethod" style="document" />
Chapter 8 - Advanced C# Type Construction Techniques
<input>
Part Three - Programming with .NET Assemblies
<soap:body use="literal" />
Chapter 9 - Understanding .NET Assemblies
</input>
Chapter 10 - Processes, AppDomains, Contexts, and Threads
<output>
Chapter 11 - Type Reflection, Late Binding,use="literal"and A tribute-Based Programming
<soap:body />
Part Four - Leveraging</output>the .NET Libraries
Chapter </operation>12 - Object Serialization and the .NET Remoting Layer
Chapter</binding>13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
ChaptTher<service>16 - The SystemElement.IO Nam space
Chapter 17 - Data Access with ADO.NET
PartFinallyFivewe- WebhaveApplicationsthe <service>andelement,XML WebwhichServicesspecifies the characteristics of the Web service itself (such as its
ChapterURL). The18 -chiefASP.NETdutyWebof thisPageselementand Webis toControlsdescribe the set of ports exposed from a given Web server. To do so, Chapterthe <services>19 - ASPelement.NET WebmakesApplicationsuse of any number of <port> subelements (not to be confused with the
<portType> element.
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Viewing theC#HelloWSand the .NETWSDLPlatform,DocumentSe ond Edition
by Andrew Troelsen |
ISBN:1590590554 |
Now that you have received a high-level tour of the various blocks of information contained in a WSDL docume
Apress © 2003 (1200 pages)
let's conclude our investigation of WSDL by viewing the WSDL definition for the HelloWS XML Web service
This comprehensive text starts with a brief overview of the
created at the onsetC# languageof this chapternd then. Toquicklydo so, movesnavigateto tokeythetechnicalURL containingand the HelloWorldWS.asmx file and click the Service Descriptionarchitec urallinkssues(orforsimply.NETappenddevelopers"?WSDL". to the URL query string).
As you can see, the root <definitions> element is indeed adorned with numerous XML namespace definitions. T
Table<types>of Contsubelementnts is quite sparse, given that we have defined a single Web method that takes no arguments C#andandreturnshe .NETa simplePlatform,stringSecondtype (ifEditionyou are interested in viewing how parameters are represented in WSDL synt
pull up the WSDL document for the CalcWebService and check out the description of the Add() Web method):
Introduction
Part One - Introducing C# and the .NET Platform
Chapter<!-- Definitions1 - The Philo ophyof ofthe.NETtypes -->
Chapter<types>2 - Building C# Applications
Part Two<s:schema- The C# PrograelementFormDefault="qualified"ming Language targetNamespace="http://tempuri.org
Chapter<s:element3 - C# Languagename="HelloWorld">Fundamentals
<s:complexType />
Chapter 4 - Object-Oriented Programming with C#
</s:element>
Chapter 5 - Exceptions and Object Lifetime
<s:element name="HelloWorldResponse">
Chapter 6 - Interfaces and Collections
<s:complexType>
Chapter 7 - Callback Interfaces, Delegates, and Events
<s:sequence>
Chapter 8 - Advanced C# Type Construction Techniques
<s:element minOccurs="0" maxOccurs="1"
Part Three - Programming with .NET Assemblies
name="HelloWorldResult" type="s:string" />
Chapter 9 - Understanding .NET Assemblies
</s:sequence>
Chapter 10 - Processes, AppDomains, Contexts, and Threads
</s:complexType>
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
</s:element>
Part Four - Leveraging the .NET Libraries
</s:schema>
Chapter 12 - Object Serialization and the .NET Remoting Layer
</types>
Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
ChapterAs mentioned,15 - Programmingthe role ofwiththe <message>Windows FormselementCo trolsis to describe the characteristics of the HTTP request and
Chapterresponse16 cycle:- The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part<!--FiveDefinitions- Web Applicationsof andtheXMLmessagesWeb S rvices-->
Chapter<message18 - ASPname="HelloWorldSoapIn">.NET b Pages and Web Controls
Chapter <part19 - ASPname="parameters".NET Web Applica ions element="s0:HelloWorld" />
Chapt</message>r 20 - XML Web Services
<message name="HelloWorldSoapOut">
Index
<part name="parameters" element="s0:HelloWorldResponse" />
List of Figures
</message>
List of Tables
The <port> and <binding> elements are defined as so:
<!-- Port information -->
<portType name="HelloClassSoap"> <operation name="HelloWorld">
<input message="s0:HelloWorldSoapIn" /> <output message="s0:HelloWorldSoapOut" />
</operation>
</portType>
<!-- Binding information -->
<binding name="HelloClassSoap" type="s0:HelloClassSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
C# and the .NET Platform, Second Edition
<operation name="HelloWorld">
by Andrew Troelsen ISBN:1590590554
<soap:operation soapAction="http://tempuri.org/HelloWorld"
Apress © 2003 (1200 pages)
style="document" />
This comprehensive text starts with a brief overview of the
<input>
C# language and then quickly moves to key technical and
<soap:body use="literal" /> architectural issues for .NET developers.
</input>
<output>
<soap:body use="literal" />
Table of Contents
</output>
C# and the .NET Platform, Second Edition
</operation>
Introduction
</binding>
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
PartAndTwofinally,- ThethereC# Programmingis the <service>Languageelement, which describes the HelloWS itself:
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
<!-- Definitions of the WS -->
Chapter 5 - Exceptions and Object Lifetime
<service name="HelloClass">
Chapter 6 - Interfaces and Collections
<port name="HelloClassSoap" binding="s0:HelloClassSoap">
Chapter 7 - Callb<soap:addressck Interface , Delegalocation="http://localhost/HelloWS/HelloWorldWSes, and Events .asmx" />
Chapter </port>8 - Advanced C# Type Construction Techniques
Part</service>Th ee - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
As you can see, WSDL documents tend to be quite verbose. The good news is that you can lead a productive a
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
happy life as a .NET XML Web service developer without becoming an expert in the nuances of WSDL syntax.
Part Four - Leveraging the .NET Libraries
Although you are always free to create a *.wsdl document by hand, the chances that you will do so are extreme
Chapter 12 - Object Serialization and the .NET Remoting Layer
rare. However, having a basic understanding of WSDL will serve you well, especially if you need to tweak the
Chapter 13 - Building a Better Window (Introducing Windows Forms) default element definitions emitted by IIS.
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Note Recall that the System.Web.Services.Description namespace contains a plethora of types that allow Chapter 16 to- TheprogrammaticallySystem.IO Namreadspaceand manipulate raw WSDL (so check it out if you are so interested).
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
The wsdl.exeC# andCommandthe .NET Platform,Line SecondUtilityEdition
by Andrew Troelsen |
ISBN:1590590554 |
Now that you have a better understanding of WSDL's place in the world, you are ready to check out a
Apress © 2003 (1200 pages)
command-line tool that ships with the .NET SDK named (surprise, surprise) wsdl.exe. In a nutshell, this tool
This comprehensive text starts with a brief overview of the performs two majorC# tasks:l nguage and then quickly moves to key technical and
architectural issues for .NET developers.
Generates a server-side file that functions as a skeleton for implementing the XML Web service
Generates a client-side file that functions as the proxy to the remote XML Web service
Table of Contents
C# and the .NET Platform, Second Edition
Wsdl.exe supports a number of command-line flags. While you may view all possible options by typing
Introduction
wsdl -? at the command prompt, Table 20-5 points out some of the more common arguments (do note
Part One - Introducing C# and the .NET Platform |
|||||||||
|
that each flag supports a shorthand notation as well, which can also be seen via command prompt help). |
||||||||
Chapter 1 |
- The Philosophy of .NET |
||||||||
Chapter 2 |
- Building C# Applications |
||||||||
|
Table 20-5: Select Flags of wsdl.exe |
|
|||||||
Part Two - The C# Programming |
Language |
|
|
|
|||||
ChapterWsdl.exe3 - C# Language |
FundamentalsMeaning in Life |
|
|
||||||
ChapterCommand4 --ObjectLine-Oriented |
Programming with C# |
|
|
||||||
|
ChapterFlag5 |
- Exceptions and |
|
Object Lifetime |
|
|
|||
|
|
|
|
|
|
|
|||
|
|
Chapter 6 |
- Interfaces and |
|
|
Collections |
|
|
|
|
|
/appsettingurlkey |
|
|
This option instructs wsdl.exe to build a proxy that does not make use of |
|
|
||
|
Chapter 7 |
- Callback Interfaces, Delegates, and Events |
|
|
|||||
|
|
|
|
|
|
hard-coded URLs. Instead, the proxy class will be configured to read the |
|
|
|
|
Chapter 8 |
- Advanced C# Type Construction Techniques |
|
|
|||||
|
|
|
|
|
|
URL from a client-side *.config file. |
|
|
|
|
|
|
|
|
|
||||
Part Three - Programming with .NET Assemblies |
|
|
|||||||
|
|
/language |
|
|
Specifies the language to use for the generated proxy class: |
|
|
||
Chapter 9 |
- Understanding .NET Assemblies |
|
|
||||||
Chapter 10 |
- Processes, AppDomains,CS (C#;Contexts,default) and Threads |
|
|
||||||
Chapter 11 |
- Type Reflection, Late Binding, nd Attribute-Based Programming |
|
|
||||||
|
|
|
|
|
|
VB (Visual Basic .NET) |
|
|
|
Part Four - Leveraging the .NET Libraries |
|
|
|||||||
Chapter 12 |
|
|
|
JS (JScript) |
|
|
|||
- Object Serialization and the .NET Remoting Layer |
|
|
|||||||
|
|
|
|
|
|
VJS (Visual J#). The default is C#. |
|
|
|
|
Chapter 13 |
- Building a Better |
|
Window (Introducing Windows Forms) |
|
|
|||
|
|||||||||
|
|
Chapter 14 |
- A Better Painting |
|
|
Framework (GDI+) |
|
|
|
|
|
/namespace |
|
|
Specifies the namespace for the generated proxy or template. By |
|
|
||
|
Chapter 15 |
- Programming with Windows Forms Controls |
|
|
|||||
|
|
|
|
|
|
default your type will not be defined within a namespace definition! |
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Chapter 16 |
- The System.IO |
|
Namespace |
|
|||
|
|
/out |
- Data Access with |
Specifies the file in which to save the generated proxy code. If not |
|
|
|||
|
Chapter 17 |
ADO.NET |
|
|
|||||
|
|
|
|
|
|
specified, the file name is based on the XML Web service name. |
|
|
|
Part Five - Web Applications |
|
|
and XML Web Services |
|
|
Cha/protocolter 18 - ASP.NET Web PagesSpecifiesand WebtheControlsprotocol to use within the proxy code. SOAP is the default.
Chapter 19 - ASP.NET Web ApplicationsHowever, you can also specify HttpGet or HttpPost to create a proxy that Chapter 20 - XML Web Servicescommunicates using simple HTTP GET or POST verbs.
Index
/server
List of Figures
List of Tables
Generates an abstract class for an XML Web service based on the WSDL document.
Transforming WSDL into an XML Web Service Skeleton
One interesting use of the wsdl.exe utility is to generate a skeleton class definition in the language of your choice. Once this source code file has been generated, you have a solid starting point to provide the actual implementation of each Web method. To illustrate, open a command window and specify the /server flag, followed by the name of the WSDL document you wish to process. Note that the WDSL document may be contained in a physical *.wsdl file:
wsdl /server SimpleHelloWS_wsdl.wsdl
or can be obtained dynamically from a given URL via the ?WSDL suffix:
wsdl /server http://localhost/helloWS/HelloWorldWS.asmx?WSDL
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
In either case, onceThisthecomprehensivewsdl.exe tooltexthasstartsprocessedwith a thebriefWSDLovervielements,w of the you will end up with a C# source code file (if you wishC# languageto receiveanda filethenwrittenquicklywithmovesa differentto keymanagedtechnical andlanguage, simply make use of the /language flag): architectural issues for .NET developers.
using System.Diagnostics;
Table of Contents
using System.Xml.Serialization;
C# and the .NET Platform, Second Edition
using System;
Introduction
using System.Web.Services.Protocols;
Part One - Introducing C# and the .NET Platform
using System.ComponentModel;
Chapter 1 - The Philosophy of .NET using System.Web.Services;
Chapter 2 - Building C# Applications
[System.Web.Services.WebServiceBindingAttribute
Part Two - The C# Programming Language
(Name="HelloClassSoap", Namespace="http://tempuri.org/")]
Chapter 3 - C# Language Fundamentals
public abstract class HelloClass : System.Web.Services.WebService
Chapter 4 - Object-Oriented Programming with C#
{
Chapter 5 - Exceptions and Object Lifetime
[System.Web.Services.WebMethodAttribute()]
Chapter 6 - Interfaces and Collections
[System.Web.Services.Protocols.SoapDocumentMethodAttribute
Chapter 7 - Callback Interfaces, Delegates, and Events
("http://tempuri.org/HelloWorld",
Chapter RequestNamespace="http://tempuri8 - Advanced C# Type Cons ruction Techniques.org/",
Part ThreeResponseNamespace="http://tempuri- Programming with .NET Assemblies .org/",
Chapter Use=System9 - Understanding.Web.NETServicesAssemblies.Description.SoapBindingUse.Literal,
Chapter ParameterStyle=System10 - Processes, AppDomains, Contexts,.Web.Servicesand Threads.Protocols.SoapParameterStyle.Wrapped)]
public abstract string HelloWorld();
Chapter 11 - Type Reflection, Late Binding, and Att ibute-Based Programming
}
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Again, note that the generated class type is simply a shell that you can use to implement the methods of the
Chapter 14 - A Better Painting Framework (GDI+)
XML Web service. Notice, for example, that the HelloClass type and HelloWorld() method have both been
Chapter 15 - Programming with Windows Forms Controls defined as abstract entities.
Chapter 16 - The System.IO Namespace
ChapterAlthough17this- Datais aAccessvery interestingwith ADO.featureNET of the wsdl.exe utility, the chances are that you would rather have
PartthisFivetool -goWebin theApplicationsother directionand XMLandWebgenerateServicesa client-side proxy type that will communicate with the
Chapterremote18Web- ASPservice.NET.WebYouPagessee howandtoWebdo Controlsthis very thing in just a moment. But first, let's dive a bit deeper into
Chapterthe wire19protocols- ASP.NET. Web Applications
Chapter 20 - XML Web Services
SOURCE |
The SimpleHelloWS_WSDL.wsdl and proxy skeleton files can be found under the |
Index |
Chapter 20 subdirectory. |
CODE |
|
List of Figures |
|
List of Tables |
|
Revisiting theC# andXMLthe .WebNET Platform,ServiceSecondWireEditionProtocols
by Andrew Troelsen |
ISBN:1590590554 |
As you know, the purpose of a Web service is to return XML-based data to a consumer, using the HTTP
Apress © 2003 (1200 pages)
protocol. Specifically, a Web server bundles this data into the body of an HTTP request and transmits it to
This comprehensive text starts with a brief overview of the the consumer usingC# onelanguageof threeandspecificth n quicklytechniquesmov (toTablekey technical20-6). and
architectural issues for .NET developers.
Table 20-6: Web Service Wire Protocols
|
|
|
|
|
TableTransmissionof Contents |
|
Meaning in Life |
|
|
C#Protocoland the .NET Platform, Second Edition |
|
|||
|
|
|
|
|
|
Introduction |
|
GET submissions append parameters to the query string of the current |
|
|
HTTP GET |
|
|
|
Part One - Introducing C# and |
the .NET Platform |
|
||
|
|
|
URL. |
|
|
Chapter 1 - The Philosophy |
|
of .NET |
|
|
|
|
||
|
ChapterHTTP2POST- Building C# ApplicationsPOST transmissions embed the data points into the header of the |
|
||
Part Two - The C# ProgrammingHTTPLanguagemessage rather than appending them to the query string. |
|
|||
|
|
|
|
|
Chapter 3
SOAP
Chapter 4
- C# Language Fundamentals
SOAP is a wire protocol that specifies how to submit data and invoke
- Object-Oriented Programming with C#
methods across the wire using XML.
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
ChaptWhilereach7 - approachCallback Interfaces,leads to theD legates,same resultand Events(invoking a Web method), your choice of wire protocol
determines the types of parameters (and return types) that can be sent between each interested party.
Chapter 8 - Advanced C# Type Construction Techniques
The SOAP protocol offers you the greatest form of flexibility, given that SOAP messages allow you to pass
Part Three - Programming with .NET Assemblies
complex data types between the caller and XML Web service (as well as binary files). However, for
Chapter 9 - Understanding .NET Assemblies
completion let's check out the role of standard GET and POST.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartHTTPFour -GETLeveragingandtheHTTP.NET LibrariesPOST Messages
Chapter 12 - Object Serialization and the .NET Remoting Layer
Although GET and POST verbs may be familiar constructs, you must be aware that this method of
Chapter 13 - Building a Better Window (Introducing Windows Forms)
transportation is not rich enough to represent such complex items as structures or classes. When you use
Chapter 14 - A Better Painting Framework (GDI+)
GET and POST verbs, you can only interact with Web methods using the types listed in Table 20-7.
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
|
Table 20-7: Supported POST and GET Data Types |
||||
|
|
Chapter 17 - Data Access with ADO.NET |
|||
|
|
|
|
|
|
Part Five - Web Applications |
|
and XML Web Services |
|
||
|
|
Supported |
|
Meaning in Life |
|
Chapter 18 - ASP.NET Web |
|
Pages and Web Controls |
|
||
|
|
GET/POST Data |
|
|
|
Chapter 19 - ASP.NET Web |
|
Applications |
|
||
|
|
Type |
|
|
|
|
|
|
|
|
|
|
|
Chapter 20 - XML Web Services |
|
||
|
|
Enumerations |
|
GET and POST verbs support the transmission of .NET System.Enum |
|
Index |
|
types, given that these types are represented as a static constant string. |
|
||
List of Figures |
|
|
|||
|
|
|
|||
|
|
Simple Arrays |
|
You can construct arrays of any primitive type. |
|
List of Tables |
|
|
|
||
|
|
|
|
|
|
|
|
Strings |
|
GET and POST transmit all numerical data as a string token. String |
|
|
|
|
|
really refers to the string representation of CLR primitives such as Int16, |
|
|
|
|
|
Int32, Int64, Boolean, Single, Double, Decimal, and so forth. |
|
|
|
|
|
|
|
If you make use of standard HTTP GET or HTTP POST, you are not able to build Web methods that take complex types as parameters or return values (for example, an ADO.NET DataSet or custom structure type). For simple Web services, this limitation may be acceptable. However, if you make use of SOAP messages, you are able to build much more elaborate XML Web services.
SOAP Messages
Although a complete examination of SOAP is outside the scope of this text, understand that SOAP itself does not define a specific protocol and can thus be used with any number of existing Internet protocols (HTTP, SMTP, and others). The general role of SOAP, however, remains the same: Provide a mechanism
to invoke methods using complex types in a languageand platform-neutral manner. To do so, SOAP
C# and the .NET Platform, Second Edition encodes each complex method using SOAP messages.
by Andrew Troelsen ISBN:1590590554
In a nutshell, a SOAPApressmessage© 2003 (1200definespag )two core sections. First we have the SOAP envelope, which can be understood asThisthecomprehensiveconceptual containertext startsfor thewithrelevanta brief overviewinformationof the. Second, we have the rules that are used to describeC# languagethe informationand theninquicklysaid messagemoves to(placedkey technicalinto theandSOAP body). An optional third
architectural issues for .NET developers.
section (the SOAP header) may be used to specify general information regarding the message itself such as security or transactional information.
Table of Contents
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
C# and the .NET Platform, Second Edition
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Introduction
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Part One - Introducing C# and the .NET Platform
<soap:Header>
Chapter 1 - The Philosophy of .NET
<!-- Optional header information -->
Chapter 2 - Building C# Applications
</soap:Header>
Part Two - The C# Programming Language
<soap:Body>
Chapter 3 - C# Language Fundamentals
<!-- Method invocation information -->
Chapter 4 - Object-Oriented Programming with C#
</soap:Body>
Chapter 5 - Exceptions and Object Lifetime
</soap:Envelope>
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterViewing8 -aAdvancedSOAPC#MessageType Construction Techniques
Part Three - Programming with .NET Assemblies
Like other aspects of WSDL, you are not required to understand the inner details of SOAP to build XML
Chapter 9 - Understanding .NET Assemblies
Web services with the .NET platform. However, when you use the makeshift client browser, you are able
Chapter 10 - Processes, AppDomains, Contexts, and Threads
to view the format of the SOAP message for each exposed Web method. For example, if you were to click
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
the link for the Add() method of the CalcWebService, you would find the following SOAP request:
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Chapter 13 - Building a Better Window (Introducing Windows Forms)
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Chapter 14 - A Better Painting Framework (GDI+)
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
Chapter 15 - Programming with Windows Forms Controls
<soap:Body>
Chapter 16 - The System.IO Namespace
<Add xmlns="http://www.intertech-inc.com/WebServices">
Chapter 17 - Data Access with ADO.NET
<x>int</x>
Part Five - Web Applications and XML Web Services
<y>int</y>
Chapter 18 - ASP.NET Web Pages and Web Controls
</Add>
Chapter 19 - ASP.NET Web Applications
</soap:Body>
Chapter 20 - XML Web Services
</soap:Envelope>
Index
List of Figures
List of Tables
The corresponding SOAP response looks like this:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddResponse xmlns="http://www.intertech-inc.com/WebServices"> <AddResult>int</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
TransformingC# andWSDLthe .NETintoPlatform,C# CodeSecond (GeneratingEdition a Proxy)
by Andrew Troelsen |
ISBN:1590590554 |
At this point, you are ready to build custom clients that can consume your XML Web services. Although
Apress © 2003 (1200 pages)
undesirable, it is completely possible to construct a client-side code base that manually requests a WSDL
This comprehensive text starts with a brief overview of the
definition and manuallyC# languageparsesandeacht enXMLquicklynodemtovestablishto key ateconnectionhnical and to the remote service. A muchpreferred approacharchitecturalis to leverageissueswsdlfor..exeNETtodevelopersgenerate.a proxy class that maps to the Web methods defined by a given *.asmx file. To do so, specify the name of proxy file to be generated (via the /out flag) and the URL where the WSDL can be obtained:
Table of Contents
C# and the .NET Platform, Second Edition
wsdl.exe /out:c:\MyCalcWSProxy.cs
Introduction
http://localhost/CSharpBookSE/CalcWebService/CalcWS.asmx?WSDL
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChaptBy default,r 2 -wsdlBuilding.exeC#willApplicationsgenerate proxy code written in C#. However, if you wish to obtain proxy code in an
Palternativert Two - The.NETC# language,Pro r mmingmakeLanguageuse of the /language flag. You should also be aware that by default,
Chapterwsdl.exe3 will- C#generateLanguageproxyFundamentalsthat communicates with the remote XML Web service using SOAP. If you wish Chapterto build4a proxy- Objectthat-OrientedleveragesProgrstraightmmingHTTPwithGETC# or HTTP POST, you may make use of the /protocol flag.
Chapter 5 - Exceptions and Object Lifetime
ChaptInvestigatingr 6 - In erfacestheand CollectionsProxy Code
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterIf you opened8 - Advancedup the generatedC# Type Construction*.cs file, youTechniqueswould find that you are given a class type that derives from PartSystemThree.Web- Programming.Services.Protocolswith .NET.SoapHttpClientProtocolAssemblies . This base class defines a number of helper
functions that will be leveraged within the implementation of the proxy type. Table 20-8 describes some
Chapter 9 - Understanding .NET Assembli s
interesting inherited members.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Table 20-8: Core Members of the SoapHttpClientProtocol Type
Part Four - Leveraging the .NET Libraries
|
|
|
|
|
|
Chapter 12 - Object Serialization and the .NET Remoting Layer |
|
||
|
Inherited |
|
Meaning in Life |
|
|
Chapter 13 - Building a Better Window (Introducing Windows Forms) |
|
||
|
Member |
|
|
|
|
Chapter 14 - A Better Painting |
Framework (GDI+) |
|
|
|
|
|||
|
ChapterBeginInvoke()15 - Programming |
|
withStartsWindowsan asynchronousForms Controlsinvocation of the Web method |
|
|
|
|||
|
Chapter 16 - The System.IO |
|
Namespace |
|
|
EndInvoke() |
|
Ends an asynchronous invocation of the Web method |
|
|
Chapter 17 - Data Access with ADO.NET |
|
||
|
|
|||
PartInvoke()Five - Web Applications |
|
Synchronouslyand XML Web Servicesinvokes a method of the Web service |
|
|
|
|
|
|
|
|
Chapter 18 - ASP.NET Web |
|
Pages and Web Controls |
|
|
Proxy |
|
Gets or sets proxy information for making a Web service request through a |
|
|
Chapter 19 - ASP.NET Web |
|
Applications |
|
|
|
|
firewall |
|
|
Chapter 20 - XML Web Services |
|
||
|
|
|||
|
Timeout |
|
Gets or sets the timeout (in milliseconds) used for synchronous calls |
|
Index |
|
|
|
|
|
|
|
||
|
|
|
|
|
List of Figures |
|
Gets or sets the base URL to the server to use for requests |
|
|
|
Url |
|
|
|
|
|
|
|
|
List of Tables |
|
Gets or sets the value for the user agent header sent with each request |
|
|
|
UserAgent |
|
|
The constructor of this proxy class hard codes the URL of the remote Web service and stores it in the inherited Url property:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(
Name="MyWayCoolWebCalculatorSoap",
Namespace="http://www.intertech-inc.com/WebServices")]
public class MyWayCoolWebCalculator :
System.Web.Services.Protocols.SoapHttpClientProtocol
{
public MyWayCoolWebCalculator()
...
}
{
C# and the .NET Platform, Second Edition
this.Url = "http://localhost/CSharpBookSE/CalcWebService/CalcWS.asmx";
} by Andrew Troelsen ISBN:1590590554
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
The generated proxy code defines synchronous and asynchronous members for each Web method defined in
the Web service. As you are aware, synchronous method invocations are blocked until the call returns.
Table of Contents
Asynchronous method inoculations return control to the calling client immediately after sending the invocation
C# and the .NET Platform, Second Edition
request. When the processing has finished, the runtime makes a callback to the client. Here is the
Introduction
synchronous implementation of the Add() method which takes two System.Int32 types (recall that we
Part One - Introducing C# and the .NET Platform
overloaded this method):
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
Part Two - The C# Programming Language
"http://www.intertech-inc.com/WebServices/Add",
Chapter 3 - C# Language Fundamentals
RequestNamespace="http://www.intertech-inc.com/WebServices",
Chapter 4 - Object-Oriented Programming with C#
ResponseNamespace="http://www.intertech-inc.com/WebServices",
Chapter 5 - Exceptions and Object Lifetime
Use=System.Web.Services.Description.SoapBindingUse.Literal,
Chapter 6 - Interfaces and Collections
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Chapter 7 - Callback Interfaces, Delegates, and Events public int Add(int x, int y)
Chapter{ 8 - Advanced C# Type Construction Techniques
Part Threeobject[]- Programmingresultswith .NET= thisAssemblies.Invoke("Add",
Chapter 9 - Undnewrstandingobject[].NET Assemblies{x, y});
Chapter return10 - P ocesses,((int)(results[0]));AppDomains, Contexts, and Threads
}
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
The asynchronous version of this Add() method is represented by the now familiar BeginXXXX() / EndXXX()
Chapter 13 - Building a Better Window (Introducing Windows Forms) method pair:
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
public System.IAsyncResult BeginAdd(int x, int y, System.AsyncCallback callback,
Chapter 16 - The System.IO Namespace
object asyncState)
Chapter 17 - Data Access with ADO.NET
{
Part Five - Web Applications and XML Web Services
return this.BeginInvoke("Add",
Chapter 18 - ASP.NET Web Pages and Web Controls
new object[] {x, y}, callback, asyncState);
Chapter 19 - ASP.NET Web Applications
}
Chapter 20 - XML Web Services
public int EndAdd(System.IAsyncResult asyncResult)
Index
{
List of Figures
object[] results = this.EndInvoke(asyncResult);
List of Tablesreturn ((int)(results[0]));
}
The remaining proxy methods are implemented more or less the same way. In a nutshell, each synchronous method packages any incoming parameters into a generic array of System.Object types and passes them into the inherited Invoke() method. The return value (if any) is cast into a .NET specific type. The asynchronous methods take a similar approach, however they make use of the inherited BeginInvoke() and EndInvoke() methods.
Wrapping the Proxy Type Within a .NET Namespace
One update you will want to make for the generated proxy file is to wrap the class in a namespace definition, as shown here:
namespace CalcWSClient
{
C# and the .NET Platform, Second Edition public class MyWayCoolWebCalculator :
by Andrew Troelsen ISBN:1590590554
System.Web.Services.Protocols.SoapHttpClientProtocol
{...} Apress © 2003 (1200 pages)
}This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
By default, wsdl.exe will not define a specific namespace unless you explicitly specify the /n flag at the
command prompt. For example:
Table of Contents
C# and the .NET Platform, Second Edition
wsdl.exe /out:c:\MyCalcWSProxy.cs /n:CalcWSClient
Introduction
http://localhost/CSharpBookSE/CalcWebService/CalcWS.asmx?WSDL
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Leveraging the Proxy (Synchronous Invocations) |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Once you have your proxy file, you can either compile the type into a stand-alone .NET assembly (via csc.exe)
Apress © 2003 (1200 pages)
simply include the *.cs file directly in your client application. In either case, you need to explicitly set a reference
This comprehensive text starts with a brief overview of the
the System.Web.C#Serviceslanguage.dll assemblynd then quickly(givenmovesthat thetoproxykey technicalcode makesand use of numerous types defined within
this binary). architectural issues for .NET developers.
At this point the client will simply create an instance of the proxy type and call the methods of interest. All of the
Tablegrungeof Contentswork of opening an HTTP channel, formatting the SOAP message, and mapping XML to and from .NE
C#dataandtypesthe .NETis handledPlatform,onSecondyour behalfEdition.
Introduction
Assume you have created a new C# console application project that directly includes the *.cs proxy file and
Part One - Introducing C# and the .NET Platform
wraps it into the client's namespace. The client code is straightforward:
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
// Don't forget to set a reference to
Part Two - The C# Programming Language
// System.Web.Services.dll!
Chapter 3 - C# Language Fundamentals
using System;
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
{
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
{
Chapter 8 - Advanced C# Type Construction Techniques
static void Main(string[] args)
Part Three - Programming with .NET Assemblies
{
Chapter 9 - Understanding .NET Assemblies
// Exercise the proxy!
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Console.WriteLine("***** The amazing Web Service Client App *****\n"
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
MyWayCoolWebCalculator ws = new MyWayCoolWebCalculator();
Part Four - Leveraging the .NET Libraries |
|
|
|
Console.WriteLine("2 + 3 = {0}", ws.Add(2, 3)); |
|
Chapter 12 - Object Seria ization and the .NET Remoting Layer |
Add(23.4F, 33.1F)); |
|
|
Console.WriteLine("23.4 + 33.1 = {0}", ws. |
|
Chapter 13 - Building a Better Window (Introducing Windows Forms) |
|
|
|
Console.WriteLine("My random number is: {0}", |
|
Chapter 14 |
- A Better Paintingws.GetMyRandomNumberFramework (GDI+) ()); |
|
Chapter 15 |
- ProgrammingConsolewith.WriteLine("SimpleWindows Forms Controlsvalue of PI is: {0}", |
|
Chapter 16 |
- The System.IOws.GetSimplePINames ace ()); |
|
Chapter 17 |
- DataConsole.WriteLine();Access with ADO.NET |
|
}
Part Five - Web Applications and XML Web Services
Chapter}18 - ASP.NET Web Pages and Web Controls
}
Chapter 19 - ASP.NET Web Applications Chapter 20 - XML Web Services
Index
ListRegardingof Figures Overloaded Web Methods
List of Tables
One point of interest is the fact that the overloaded Add() method defined by the Web service indeed is realized by the client as an overloaded method. Recall that WSDL demands a unique name for each method it is describing (therefore, we are required to make use of the MessageName property when applying the [WebService] attribute). However, if you look at the proxy code, you will find that the System.Web.Services.Protocols.SoapDocumentMethodAttribute type maps the overloaded method to the corre underlying WSDL name, for example:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute
("http://www.intertech-inc.com/WebServices/Add",
RequestNamespace="http://www.intertech-inc.com/WebServices",
ResponseNamespace="http://www.intertech-inc.com/WebServices",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int Add(int x, int y)
{...}
[System.Web.Services.WebMethodAttribute(MessageName="Add1")]
C# and the .NET Platform, Second Edition
[System.Web.Services.Protocols.SoapDocumentMethodAttribute
by Andrew Troelsen ISBN:1590590554
("http://www.intertech-inc.com/WebServices/AddFloats",
Apress © 2003 (1200 pages)
RequestElementName="AddFloats",
This comprehensive text starts with a brief overview of the
RequestNamespace="http://www.intertech-inc.com/WebServices",
C# language and then quickly moves to key technical and
ResponseElementName="AddFloatsResponse", architectural issues for .NET developers.
ResponseNamespace="http://www.intertech-inc.com/WebServices",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Table of Contents
[return: System.Xml.Serialization.XmlElementAttribute("dddFloatsResult")]
C# and the .NET Platform, Second Edition
public System.Single Add(System.Single x, System.Single y)
Introduction
{...}
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
LeveragingC#theandProxythe .NET(AsynchronousPlatform, Sec d EditionInvocations)
by Andrew Troelsen |
ISBN:1590590554 |
As you have seen at numerous points throughout this text, the .NET platform has native support for
Apress © 2003 (1200 pages)
asynchronous method invocations. The task of asynchronously invoking a method exposed from a given
This comprehensive text starts with a brief overview of the
XML Web serviceC#underlanguage.NETandis oncethenagainquicklybasedmovesontothekeydelegatetechnicalpatternand . Thus, if you wish to asynchronously invokearchitecturalany ofissuesthe methodsfor .NETexposeddevelopersby.the Calculator XML Web Service, simply leverage the BeginXXX() and EndXXXX() methods.
TableRecallof thatContentswhen you wish to invoke a method asynchronously, the IAsyncResult interface allows you to C#gatherand thethe.method'sNET Platforeturnm, SecondvalueEditionas well as determine if the call has completed. Thus, you may call Add()
asynchronously as follows:
Introduction
Part One - Introducing C# and the .NET Platform
ChapterIAsyncResult1 - The Philoresultophy of= .NETws.BeginAdd(30, 21, null , null);
Chapter... 2 - Building C# Applications
Partif(resultTwo - The.C#IsCompletedProgramming) Language
Chapter Console3 - C# Language.WriteLine("30Fu damentals+ 32 = {0}", ws.EndAdd(result));
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
If you would rather have the XML Web service call back to the client-side code base (rather than poll the
Chapter 6 - Interfaces and Collections
method via the IsCompleted property), you can make use of the AsyncCallback delegate:
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
// Assume 'ws' is a static instance of the Calc proxy.
Part Three - Programming with .NET Assemblies
AsyncCallback cb = new AsyncCallback(AdditionDone);
Chapter 9 - Understanding .NET Assemblies
IAsyncResult result = ws.BeginAdd(30, 21, cb, null);
Chapter 10 - Processes, AppDomains, Contexts, and Threads
...
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming public static void AdditionDone(IAsyncResult result)
Part Four - Leveraging the .NET Libraries
{
Chapter 12 - Object Serialization and the .NET Remoting Layer
Console.WriteLine("30 + 32 = {0}", ws.EndAdd(result));
Chapter 13 - Building a Better Window (Introducing Windows Forms)
}
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part FiveSOURCE- Web ApplicationsThe CalcWSClientnd XML WebprojectServicescan be found under the Chapter 20 subdirectory.
CODE
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Avoiding HardC# and-Codedthe .NETProxylatform,LogicSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
The default behavior of wsdl.exe is to hard code the URL of the Web service within the proxy's constructor. The
Apress © 2003 (1200 pages)
obvious drawback to this situation is that if the URL is renamed or relocated, the proxy class must be updated a
This comprehensive text starts with a brief overview of the
recompiled. To buildC# languagea more flexibleand thenproxyquicklytype,moveswsdl.toexekeyprovidestechnicaltheand/appsettingurlkey flag (which may be abbreviated to /urlkey)architectural. Whenissuesyou specifyfor .NETthisdevelopersflag at the. command line, the proxy's constructor will contain logi that reads the URL using a key contained within a client-side *.config file.
TableTo illustrate,of Contentsgenerate a proxy file for the HelloWS Web service created earlier in this chapter (note that HelloU C#is justand anthearbitrary.NET Platform,key thatSecondwill beEditionplaced in the *.config file):
Introduction
PartC:\>wsdlOne - Introducing/urlkey:C#HelloUrland the .NEThttp://localhost/helloWS/helloworldWSPlatform .asmx?WSDL
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
If you now check out the default constructor of the proxy, you will find the following logic (note that if the correct
Part Two - The C# Programming Language
cannot be found, the hard-coded URL will be used as a backup): |
|
|||
Chapter |
3 |
- C# Language Fundamentals |
|
|
Chapter |
4 |
- Object-Oriented Programming with C# |
|
|
Chapterpublic5 |
HelloClass()- Exceptions and Object Lifetime |
|
|
|
Chapter{ |
6 |
- Interfaces and Collections |
|
|
Chapter string7 - CallbackurlSettingInterfaces, Delegates,= |
and Events |
HelloUrl"]; |
||
Chapter |
8 |
- AdvancedSystem.Configuration.ConfigurationSettings.AppSettings["C# Type Construction Techniques |
||
Part Threeif- Programming((urlSettingwith!=.NETnull))Assemblies |
|
|||
Chapter |
9 |
- Understandingthis.Url =.NETurlSetting;Assemblies |
|
|
Chapter else10 - Processes, AppDomains, Contexts, and Threads |
|
|||
Chapter |
11 |
this.Url = "http://localhost/helloWS/helloworldWS.asmx"; |
||
- Type Reflection, Late Binding, and Attribute-Based Programming |
|
|||
Part} Four - Leveraging the .NET Libraries |
|
|
||
Chapter |
12 |
- Object Serialization and the .NET Remoting Layer |
|
|
Chapter |
13 |
- Building a Better Win ow (Introducing Windows Forms) |
|
|
The client-side *.config file would look like this: |
|
|||
Chapter |
14 |
- A Better Painting Framework (GDI+) |
|
|
Chapter |
15 |
- Programming with Windows Forms Controls |
|
|
<?xml version="1.0" encoding="utf-8" ?> |
|
|||
Chapter |
16 |
- The System.IO Namespace |
|
|
<configuration> |
|
|
||
Chapter |
17 |
- Data Access with ADO.NET |
|
|
|
<appSettings> |
|
|
|
Part Five - Web Applications and XML Web Services |
|
|||
|
|
<add key="HelloUrl" value="http://localhost/helloWS/helloworldWS.asmx |
||
Chapter |
18 |
- ASP.NET Web Pages and Web Controls |
|
|
|
</appSettings> |
|
|
|
Chapter |
19 |
- ASP.NET Web Applications |
|
|
</configuration> |
|
|
||
Chapter |
20 |
- XML Web Services |
|
|
Index |
|
|
|
|
List of Figures
SOURCE The HelloWSClient project can be found under the Chapter 20 subdirectory.
List of Tables
CODE
GeneratingC#a andProxythe .NETwithPlatform,VS .NETSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
Although wsdl.exe provides a number of command-line arguments that give you ultimate control over how
Apress © 2003 (1200 pages)
the resulting proxy class will be generated, VS .NET also allows you to quickly generate a proxy file using
This comprehensive text starts with a brief overview of the
the Add Web ReferenceC# languagedialogand. Tothenactivatequicklythismovestool, simplyto key tecrightni-clickal andthe References folder of the Solution Explorerarchitectur. As you canl iseesuesfromfor .FigureNET developers20-9, you. are able to obtain references to existing XML Web services located at a variety of locales.
Table of Contents
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Chapter
Chapter
Figure 20-9: The VS .NET Add Web Reference utility
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Notice that you are not only able to obtain a list of XML Web services on your local development machine,
Chapter 12 - Object Serialization and the .NET Remoting Layer
but you may also query various UDDI catalogs (which we do at the end of this chapter). In any case, once
Chapter 13 - Building a Better Window (Introducing Windows Forms)
you type a valid URL that points to a given *.wsdl or *.asmx file, your project will contain a new proxy class.
Chapter 14 - A Better Painting Framework (GDI+)
Do note that the proxy's namespace (which is based on the URL of origin) will be nested within your Chapterclient's15.NET- Programmingnamespace.withThus,Windowsif you addedForms aControlsreference to CalcWS (which is located at
Chttp://localhost/CSharpBookSE/CalcWebService/CalcWSapter 16 - The System.IO N mespace .asmx), you would need to specify
Chapterthe following17 - DataC# usingAccessdirective:with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
using TheWSClient.localhost;
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Exposing ArraysC# nd theof.NETTypesPlatform,fromSecondWebEditionMethods
by Andrew Troelsen |
ISBN:1590590554 |
So much for Math 101. The real power of Web services becomes much more evident when you build Web
Apress © 2003 (1200 pages)
methods that return complex types. To illustrate, let's create a new XML Web service (named
This comprehensive text starts with a brief overview of the
CarSalesInfoWS)C#thatlanguis capablege and ofthenprocessingquickly movesarrays,tocustomkey technicalUDTs,andand ADO.NET DataSets. First, let's examine how to buildarchitecturalWeb methodsissues forthat.NETreceivedevelopersand return. arrays of information.
Assume you have a Web method named GetSalesTagLines(), which will return an array of strings that
Tablerepresentof Contthentscurrent sales for various automobiles. Also assume you have another Web method named C#SortCarMakes()and the .NET Platform,that allowsSecondthe callerEditionto pass in an array of unsorted strings and obtain a new array of
sorted textual information:
Introduction
Part One - Introducing C# and the .NET Platform
Chnamespacept r 1 - TheCarSalesInfoWSPhilosophy of .NET
Chapter{ 2 - Building C# Applications
Part Two[WebService(Namesp- The C# Programming Languagece="http://www.intertech-inc.com/webservices",
Chapter 3Description="This- C# Language FundamentalsWeb service processes custom types")]
public class CarSalesInfoService : System.Web.Services.WebService
Chapter 4 - Object-Oriented Programming with C#
{
Chapter 5 - Exceptions and Object Lifetime
...
Chapter 6 - Interfaces and Collections
[WebMethod(Description="Get current discount blurbs")]
Chapter 7 - Callback Interfaces, Delegates, and Events
public string[] GetSalesTagLines()
Chapter 8 - Advanced C# Type Construction Techniques
{
Part Three - Programming with .NET Assemblies
string[] currentDeals = {"Colt prices slashed 50%!",
Chapter 9 - Understanding .NET Assemblies
"All BMWs come with standard 8-track",
"Free Pink Caravans...just ask me!"};
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming return currentDeals;
Part Four - Leveraging the .NET Libraries
}
Chapter 12 - Object Serialization and the .NET Remoting Layer
[WebMethod(Description="Sorts a list of car makes")]
Chapter 13 - Building a Better Window (Introducing Windows Forms)
public string[] SortCarMakes(string[] theCarsToSort)
Chapter 14 - A Better Painting Framework (GDI+)
{
Chapter 15 - Programming with Windows Forms Controls
Array.Sort(theCarsToSort);
Chapter 16 - The System.IO Namespace
return theCarsToSort;
Chapter 17 - Data} Access with ADO.NET
Part Five}- Web Applications and XML Web Services
Chapter} 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Exposing Custom# and theTypes.NET Platfromorm, SecondWebEditionMethods
by Andrew Troelsen |
ISBN:1590590554 |
The SOAP protocol is also able to transport XML representations of custom data types (both classes and
Apress © 2003 (1200 pages)
structures). Interestingly, with the current release of the .NET platform, you are not required to configure
This comprehensive text starts with a brief overview of the
these custom typesC#inlanguageany wayandto passthen quicklyor returnmovescustomto keyUDTstechnical. To illustrate,and add another Web method named GetSalesInfoDetails()archit ctural.issuesThis methodfor .NETtakesdevelopersno parameters. and returns an array of SalesInfoDetails structures:
Table of Contents
// Helper struct.
C# and the .NET Platform, Second Edition
public struct SalesInfoDetails
Introduction
{
Part One - Introducing C# and the .NET Platform
public string info;
Chapter 1 - The Philosophy of .NET
public DateTime dateExpired;
Chapter 2 - Building C# Applications
public string Url;
Part Two - The C# Programming Language
}
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
The implementation of GetSalesInfoDetails() returns a populated array of this custom UTD as follows:
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter[WebMethod(Description="Get8 - Advanced C# Type ConstructiondetailsTechniquesof current sales")]
PartpublicThree -SalesInfoDetails[]Programming with .NET AssembliesGetSalesInfoDetails()
{
Chapter 9 - Understanding .NET Assemblies
SalesInfoDetails[] theInfo = new SalesInfoDetails[3];
Chapter 10 - Processes, AppDomains, Contexts, and Threads
theInfo[0].info = "Colt prices slashed 50%!";
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
theInfo[0].dateExpired = DateTime.Parse("12/02/04");
Part Four - Leveraging the .NET Libraries
theInfo[0].Url= "http://www.CarsRUs.com";
Chapter 12 - Object Serialization and the .NET Remoting Layer
theInfo[1].info = "All BMWs come with standard 8-track";
Chapter 13 - Building a Better Window (Introducing Windows Forms)
theInfo[1].dateExpired = DateTime.Parse("8/11/03");
Chapter 14 - A Better Painting Framework (GDI+) theInfo[1].Url= "http://www.Bmws4U.com";
Chapter 15 - Programming with Windows Forms Controls
theInfo[2].info = "Free Pink Caravans...just ask me!";
Chapter 16 - The System.IO Namespace
theInfo[2].dateExpired = DateTime.Parse("12/01/09");
Chapter 17 - Data Access with ADO.NET
theInfo[2].Url= "http://www.AllPinkVans.com";
Part Five - Web Applications and XML Web Services
return theInfo;
Chapter 18 - ASP.NET Web Pages and Web Controls
}
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
A Windows Forms Client |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
At this point, you can build a client of your choosing. Simply compile the XML Web service project,
Apress © 2003 (1200 pages)
generate a proxy (a la the Add Web References dialog), and code away. For example, if you have a
This comprehensive text starts with a brief overview of the
Windows Forms clientC# languageapplication,and thenyouquicklycould fillmovesa ListBoxto keywhentechnicalyou loadand the main Form with each tag line
as follows: architectural issues for .NET developers.
private void mainForm_Load(object sender, System.EventArgs e)
Table of Contents
{
C# and the .NET Platform, Second Edition
CarSalesInfoService ws = new CarSalesInfoService();
Introduction
string[] tagLines = ws.GetSalesTagLines();
Part One - Introducing C# and the .NET Platform
foreach(string s in tagLines)
Chapter 1 - The Philosophy of .NET
lstCarSaleTagLines.Items.Add(s);
Chapter 2 - Building C# Applications
}
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
ChapterYou can4 also- Objgetctback-OrientthedarrayProgrammingof SalesInfoDetailswith C# types in response to a Button Click event as follows:
Chapter 5 - Exceptions and Object Lifetime
Chapterprivate6 -voidInterfacesbtnGetAllDetailsand Colections _Click(object sender, System.EventArgs e)
Chapter{ 7 - Callback Interfaces, Delegates, and Events
ChapterCarSalesInfoService8 - Advanced C# Type Constructionws = newTechniquesCarSalesInfoService();
Part ThreeSalesInfoDetails[]- Programming with .NETtheSkinnyAssemblies= ws.GetSalesInfoDetails();
foreach(SalesInfoDetails s in theSkinny)
Chapter 9 - Understanding .NET Assemblies
Chapter{10 - Processes, AppDomains, Contexts, and Threads
string d = string.Format("Info: {0}\nURL:{1}\nExpiration Date:{2}",
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
s.info, s.Url, s.dateExpired);
Part Four - Leveraging the .NET Libraries
MessageBox.Show(d, "Details");
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter}13 - Building a Better Window (Introducing Windows Forms)
}
Chapter 14 - A Better Painting Framework (GDI+) Chapter 15 - Programming with Windows Forms Controls Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Exposing Custom# and theTypes:.NET Platform,TheSecondDetailsEdition
by Andrew Troelsen |
ISBN:1590590554 |
As you have seen, the CarsSalesInfoWS application exposes a Web method that returns an array of
Apress © 2003 (1200 pages)
SalesInfoDetails structures, which was defined in the server application as so:
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
architectural issues for .NET developers. public struct SalesInfoDetails
{
public string info;
Table of Contents
public DateTime dateExpired;
C# and the .NET Platform, Second Edition public string Url;
Introduction
}
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChapterAgain, notice2 - Buildingthat unlikeC# Applications.NET Remoting, you are not required to mark your custom structures/classes with
ParttheTwo[Serializable]- The C# Programmingattribute. However,Languageif you wish to be more explicit that the SalesInfoDetails type is
Chapterserialized3 across- C# Languagethe wireFundamentalsas XML, you could update the structure accordingly:
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and ObjectstructLifetime
[Serializable] public SalesInfoDetails
Chapter{ 6 - Interfaces and Collections
Chapterpublic7 - CallbackstringI terfaces,info;Delegates, and Events
Chapterpublic8 - AdvancedDateTimeC# TypedateExpired;Construction Techniques
Part Threepublic- Programmingstring withUrl;.NET Assemblies
}
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
One benefit of marking custom types exposed from an XML Web service as serializable is the fact that the
Part Four - Leveraging the .NET Libraries
same type can be exposed as an MBV type from a .NET Remoting application (where you must mark
Chapter 12 - Object Serialization and the .NET Remoting Layer each MBV type with the [Serializable] attribute.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterIn either14case,- A Betterhowever,Paintheing .FrameworkNET runtime(GDI+)will serialize your custom structures and classes using the
ChapSystemr 15.Xml- Progr.Serializationmming .withXmlSerializerWindows Formsdata typeControls. This type performs the same basic role as the
ChapterBinaryFormatter16 - The Systemand SoapFormatter.IO Namespacetypes (persist a type's state to some stream), however the ChapterXmlSerializer17 - DatacanAccessonly persistwith ADOpublic.NETdata and/or private data exposed as public properties. Thus, if the
PartSalesInfoDetailsFive - Web Applicationstype was updatedand XMLasWebfollows:Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter[Serializable]19 - ASP.NET WebpublicApplicastructions SalesInfoDetails
Chapter{ 20 - XML Web Services
Index public string info;
public DateTime dateExpired;
List of Figures
public string Url;
List of Tables
private string dealershipName;
}
then the dealershipName field would not end up in the resulting XML.
Another point of interest regarding the XmlSerializer is the fact that it allows you to have intimate control over how the type is represented. To illustrate, by default the SalesInfoDetails structure is serialized as so:
<SalesInfoDetails>
<info>Colt prices slashed 50%!</info>
<dateExpired>2004-12-02T00:00:00.0000000-06:00</dateExpired>
<Url>http://www.CarsRUs.com</Url>
</SalesInfoDetails>
As you can see, each public filed/property becomes a subelement of the root <SalesInfoDetails> element.
C# and the .NET Platform, Second Edition
If you would rather expose each item of the structure as XML properties, you can mock up the structure
by Andrew Troelsen ISBN:1590590554 definitions using attributes found within the System.Xml.Serialization namespace:
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
[XmlRoot]
C# language and then quickly moves to key technical and
public struct SalesInfoDetails
architectural issues for .NET developers.
{
[XmlAttribute]public string info;
Table of[XmlAttributeContents ]public DateTime dateExpired;
[XmlAttribute]public string Url;
C# and the .NET Platform, Second Edition
}
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
which would yield the following XML data representation:
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
<SalesInfoDetails info="Colt prices slashed 50%!"
Chapter 3 - C# Language Fundamentals
ChapterdateExpired="20044 - Object-Oriented-12-Programming02T00:00:00.0000000with C# |
-06:00" |
||
ChapterUrl="http://www.CarsRUs.com"5 - Exceptions and Object Lifetime/> |
|
||
Chapter |
6 |
- Interfaces and Collections |
|
Chapter |
7 |
- Callback Interfaces, Delegates, and Events |
|
For the most part, you can typically avoid the need to adorn your custom types with XML-centric attributes. |
|||
Chapter |
8 |
- Adv ced C# Type Construction Techniqu s |
|
However, this can be extremely useful when you need to map the names of a type exposed from an XML |
|||
Part Thr |
|
- Programming with .NET Assemblies |
|
Web service into client-side counterparts. As you would hope, the attributes found within the |
|||
Chap r |
9 |
- Understanding .NET Assemblies |
|
System.Xml.Serialization namespace support various name/value pairs that may be fed into the |
|||
constructor. If you require such fine tuning, I'll assume you will check out the System.Xml.Serialization |
|||
Chapter |
10 |
- Process s, AppDomains, Co texts, and Thr ads |
Chnamespacept r 11 - Typeat yourReflleisurection,. Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
ConsumingC#Customand he .NETTypes:Platform,TheSecondDetailsEdit on
by Andrew Troelsen |
ISBN:1590590554 |
When clients set a reference to a Web service that exposes custom types, the proxy class file also
Apress © 2003 (1200 pages)
contains language definitions for each custom public type. Thus, if you were to examine the client-side
This comprehensive text starts with a brief overview of the representation ofC#thislanguagetype, youandwouldthenfindquicklythe followingmoves to C#keycode:technical and
architectural issues for .NET developers.
[System.Xml.Serialization.XmlTypeAttribute
(Namespace="http://www.intertech-inc.com/webservices")]
Table of Contents
public class SalesInfoDetails {
C# and the .NET Platform, Second Edition public string info;
Introduction
public System.DateTime dateExpired;
Part One - Introducing C# and the .NET Platform
public string Url;
Chapter 1 - The Philosophy of .NET
}
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
ChapterNow, understand,4 - Object-ofOrientedcourse,Programmingthat like .NETwithRemoting,C# types that are serialized across the wire as XML do
not retain implementation logic. Thus, if the SalesInfoDetails structure supported a set of public methods,
Chapter 5 - Exceptions and Object Lifetime
the proxy generator will fail to account for them (as they are not expressed in the WSDL document in the
Chapter 6 - Interfaces and Collections
first place!). However, if you were to distribute a client-side assembly that contained the implementation
Chapter 7 - Callback Interfaces, Delegates, and Events
code of the client-side type, you would be able to leverage the type-specific logic. Doing so, however,
Chapter 8 - Advanced C# Type Construction Techniques
would require a .NET-aware machine.
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Updating theC# andCarsSalesInfoWSthe .NET Platform, SecondProjectEdition
by Andrew Troelsen |
ISBN:1590590554 |
Let's add a final set of Web methods to the CarsSalesInfo application that will illustrate how to leverage
Apress © 2003 (1200 pages)
CLR types when constructing an XML Web service. Assume you have created another helper structure
This comprehensive text starts with a brief overview of the named Car: C# language and then quickly moves to key technical and
architectural issues for .NET developers.
public struct Car
{
Table of Contents
public Car(string p, string c, string m)
C# and the .NET Platform, Second Edition
{
Introduction petName = p;
Part One - Introducing C# and the .NET Platform
carColor = c;
Chapter 1 - The Philosophy of .NET
carMake = m;
Chapter}2 - Building C# Applications
Part Two - The C# Programming Language
public string petName;
Chapter 3 - C# Language Fundamentals
public string carColor;
Chapter 4 - Object-Oriented Programming with C# public string carMake;
Chapter} 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Next, define as private an ArrayList data member (carList) and fill it with some initial cars in the constructor
Chapter 8 - Advanced C# Type Construction Techniques
of your Web service, as shown here:
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
public class CarSalesInfoService : System.Web.Services.WebService
Chapter 10 - Processes, AppDomains, Contexts, and Threads
{
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
private ArrayList theCars = new ArrayList();
Part Four - Leveraging the .NET Libraries
public CarSalesInfoService()
Chapter 12 - Object Serialization and the .NET Remoting Layer
{
Chapter 13 - Building a Better Window (Introducing Windows Forms)
InitializeComponent();
Chapter 14 - A Better Painting Framework (GDI+)
theCars.Add(new Car("Biff", "Green", "Firebird"));
Chapter 15 - Programming with Windows Forms Controls
theCars.Add(new Car("Bunny", "Pink", "Colt"));
Chapter 16 - The System.IO Namespace
theCars.Add(new Car("Chuck", "Red", "BWM"));
Chapter 17 - Data Access with ADO.NET
theCars.Add(new Car("Mary", "Red", "Viper"));
Part Five - Web Applications and XML Web Services
theCars.Add(new Car("Mandy", "Tan", "Golf"));
Chapter 18 - ASP.NET Web Pages and Web Controls
}
Chapter 19 - ASP.NET Web Applications
...
Chapter 20 - XML Web Services
}
Index
List of Figures
Now add a method named GetCarList() which returns the entire array of autos. Another method named
List of Tables
GetACarFromList() returns a specific car from the array list based on a numerical index. The implementation of each method is simple, as shown here:
// Return a given car from the list.
[WebMethod(Description = "Get a specific car from ArrayList")] public Car GetACarFromList(int carToGet)
{
if(carToGet <= theCars.Count)
{
return (Car) theCars[carToGet];
}
throw new IndexOutOfRangeException();
}
// Return the entire set of cars.
[WebMethod(Description = "Get the ArrayList of Cars")]
public ArrayList GetCarList()
C# and the .NET Platform, Second Edition
{
by Andrew Troelsen |
ISBN:1590590554 |
return theCars; |
|
}Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
As before, the Car and ArrayList types will be exposed via XML. To wrap things up, here is one final XML Web method that interacts with the Cars database you created during your examination of ADO.NET:
Table of Contents
// Return all cars in inventory table.
C# and the .NET Platform, Second Edition
[WebMethod(Description =
Introduction
"Returns all autos in the Inventory table of the Cars database")]
Part One - Introducing C# and the .NET Platform
publicDataSet GetAllCarsFromDB()
Chapter 1 - The Philosophy of .NET
{
Chapter 2 - Building C# Applications
// Fill the DataSet with the Inventory table.
Part Two - The C# Programming Language
SqlConnection sqlConn = new SqlConnection();
Chapter 3 - C# Language Fundamentals
sqlConn.ConnectionString = "data source=.; initial catalog=Cars;" +
Chapter 4 - Object-Oriented Programming with C#
"user id=sa; password=";
Chapter 5 - Exceptions and Object Lifetime
SqlDataAdapter myDA=
Chapter 6 - Interfaces and Collections
new SqlDataAdapter("Select * from Inventory", sqlConn);
Chapter 7 - Callback Interfaces, Delegates, and Events
DataSet ds = new DataSet();
Chapter myDA8 - Advanced.Fill(ds,C# Type"Inventory");Co s ruction Techniques
Part Threereturn- P ogrammingds; with .NET Assemblies
Chapter} 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Given that the GetAllCarsFromDB() Web method returns an ADO.NET DataSet (which has already been
Part Four - Leveraging the .NET Libraries
marked as a serializable type), update the working Windows Forms client to display the results on a
Chapter 12 - Object Serialization and the .NET Remoting Layer
DataGrid widget:
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
// Fill data grid.
Chapter 15 - Programming with Windows Forms Controls
DataSet ds = ws.GetAllCarsFromDB();
Chapter 16 - The System.IO Namespace
inventoryDG.DataSource = ds.Tables["Inventory"];
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Figure 20-10 shows the final client-side GUI in action.
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Edition
ISBN:1590590554
brief overview of the
to key technical and
.
Table
C# and
Part
Chapter
Chapter
Part
Chapter
Chapter
Chapter
Chapter
Chapter
Chapter
Part
Figure 20-10: A Windows Forms XML Web Service Client application
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterSOURCE11 - Type Reflection,The CarSalesInfoWSLate Bi ding, andAttributeCarSalesInfoClient-Based Programmingprojects can be found under the Chapter
Part FourCODE- Leveraging20thesubdirectory.NET Lib aries.
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .DiscoveryNET Platform, SecondServiceEditionProtocol (UDDI)
by Andrew Troelsen |
ISBN:1590590554 |
It is a bit ironic that the typical first step taken by a client to chat with a remote Web service is the final topic
Apress © 2003 (1200 pages)
of this chapter. The reason for such an oddball flow is the fact that the process of identifying if a given Web
This comprehensive text starts with a brief overview of the
service exists usingC#UDDIlanguageis notandonlythenoptional,quickly butmovesis unnecessaryto key technicalin aandvast majority of cases.
architectural issues for .NET developers.
Until XML Web services become the de facto standard of distributed computing (which may take some time), most Web services will be leveraged by companies who are tightly coupled with a given vendor.
TableGivenofthis,Contheentscompany and vendor at large already know about each other, and therefore have no need C#toandquerythea.UDDINET Platform,server toSecondsee if theEditionWeb service in question exists. However, if the creator of an XML Web
service wishes to allow the world at large to access the exposed functionality to any number of external
Introduction
developers, the Web service may be posted to a UDDI catalog.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
UDDI is an initiative that allows Web service developers to post a commercial Web service to a well-known repository. Despite what you might be thinking, UDDI is not a Microsoft-specific ideal. In fact, IBM (Big
Blue) and Sun Microsystems have an equal interest in the success of the UDDI initiative. As you would
Chapter 3 - C# Language Fundamentals
expect, numerous vendors host UDDI catalogs. For example, Microsoft's official UDDI Web site can be
Chapter 4 - Object-Oriented Programming with C#
found at http://uddi.microsoft.com. The official Web site of UDDI (http://www.uddi.org)
Chapter 5 - Exceptions and Object Lifetime
provides numerous white papers and SDKs that allow you to build up internal UDDI servers.
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Interacting with UDDI via VS .NET
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Recall that the Add Web Reference dialog box not only allows you to obtain a list of all XML Web services
Chapter 9 - Understanding .NET Assemblies
located on your current development machine (as well as a well-known URL), but to submit queries to
Chapter 10 - Processes, AppDomains, Contexts, and Threads
UDDI servers. Basically, you have the following options:
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourBrowse- Leveforaginga UDDItheserver.NET Librarieson your internal company intranet.
Chapter 12 - Object Serialization and the .NET Remoting Layer
Browse the Microsoft-sponsored UDDI production server.
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Browse the Microsoft-sponsored UDDI test server.
Chapter 15 - Programming with Windows Forms Controls
To illustrate, assume that you are building an application that needs to discover the current weather
Chapter 16 - The System.IO Namespace
forecast on a per ZIP code basis. Your first step would be to query a UDDI catalog with the following
Chapter 17 - Data Access with ADO.NET
question:
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
"Do you know of any Web services that pertain to weather data?"
Chapter 19 - ASP.NET Web Applications
ChapterIf it is the20case- XMLthatWebtheServicesUDDI server has a list of weather-aware Web services, you are returned a list of all
Indexregistered URLs that export the functionality of your query. Referencing this list, you are able to pick the
Lispecifict of FigurWebs service you wish to communicate with, and eventually obtain the WSDL document that
Listdescribesof Tablesthe functionality of the weather-centric functionality.
To illustrate, create a brand-new Console application project and activate the Add Web Reference dialog box. Next, select the Test Microsoft UDDI Directory link, which will bring you to the Microsoft UDDI test server. At this point, enter Weather as a search criteria (Figure 20-11).
ISBN:1590590554
of the and
Table
C# and
Part
Chapter
Chapter
Part
Figure 20-11: Interacting with a UDDI catalog
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime |
|
Once the UDDI catalog has been queried, you will receive a list of all relevant XML Web services (Figure |
|
Chapter 6 - Interfaces and Collections |
|
20-12). |
|
Chapter 7 - Callback Interfaces, Delegates, and Events |
|
Chapter 8 - Advanced C# Type Construction Techniques |
|
Part |
|
Chapter |
|
Chapter |
|
Chapter |
Programming |
Part |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter |
|
Chapter
Part
Chapter
Chapter
Chapter 20 - XML Web Services
Figure 20-12: Obtaining a list of posted weather-centric Web services
Index
List of Figures
Once you find a posted XML Web service you are interested in programming against, add a reference to
List of Tables
your current project. As you would expect, the raw WSDL will be parsed by the tool to provide you with a C# proxy.
Note Understand that the UDDI test center is just that. Don't be too surprised if you find a number of broken links. Also be aware that when you query production-level UDDI servers, URLs tend to be much more reliable, given that companies may need to pay some sort of fee to be listed!
Summary C# and the .NET Platform, Second Edition
by Andrew Troelsen ISBN:1590590554
This chapter has exposed you to the core building blocks of .NET Web services. The chapter began by
Apress © 2003 (1200 pages)
examining the core namespaces (and core types in these namespaces) used during Web service
This comprehensive text starts with a brief overview of the
development. AsC#youlanguagehave seen,a dWebth n servicesquickly movesdevelopedto keyusingtechnicalthe .andNET platform require little more than applying the [WebMethod]architecturattributel iss es tof reach.NETmemberd velopersyou. wish to expose from the XML Web service type. Optionally, your types may derive from System.Web.Services.WebService to obtain access to the
Application and Session properties (among other things). This chapter also examined three key related
Table of Contents
technologies: a lookup mechanism (UDDI), a description language (WSDL), and a wire protocol (GET,
C# and the SOAP).NET latform, Second Edition
POST, or .
Introduction
Once you have created any number of [WebMethod]-enabled members, you can interact with a Web
Part One - Introducing C# and the .NET Platform
service through an intervening proxy. The wsdl.exe utility generates such a proxy, which can be used by
Chapter 1 - The Philosophy of .NET
the client like any other C# type. As an alternative to the wsdl.exe command-line tool, Visual Studio .NET
Chapter 2 - Building C# Applications
offers similar functionality via the Add Web Reference wizard.
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
|
Apress © 2003 (1200 pages) |
|
Symbols This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
–> pointer-centric operator, 360,364
architectural issues for .NET developers.
!= operator, 378–379
& pointer-centric operator, 360
Table of Contents
* and & parameters, 363
C# and the .NET Platform, Second Edition
* pointer-centric operator, 360
Introduction
Part* wildcardOne - Introducharacter,ing 50C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
*.aspx file
Chapter 2 - Building C# Applications
application cache and, 1041–1043
Part Two - The C# Programming Language
coding,954–958
Chapter 3 - C# Language Fundamentals
examining structure of, 964–965
Chapter 4 - Object-Oriented Programming with C#
*.resources (binary) files
Chapter 5 - Exceptions and Object Lifetime binding into .NET assembly, 736–737
Chapter 6 - Interfaces and Collections building,735–736
Chapter 7 - Callback Interfaces, Delegates, and Events
System.Resources namespace and, 733
Chapter 8 - Advanced C# Type Construction Techniques
*.resx files
Part Three - Programming with .NET Assemblies
creating and reading programmatically, 733–735
Chapter 9 - Understanding .NET Assemblies defined by VS .NET IDE, 739
Chapter 10 - Processes, AppDomains, Contexts, and Threads
@Page attributes, 955
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part[] pointerFour --centricL veragingoperator,the .NET360Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
+= and –+ operators, 385–386
Chapter 13 - Building a Better Window (Introducing Windows Forms)
+ operator, 375
Chapter 14 - A Better Painting Framework (GDI+)
+ token, 509
Chapter 15 - Programming with Windows Forms Controls
Chapter<, >, <=,16and- The>+Systemoperators,.IO Namespace379–380
Chapter 17 - Data Access with ADO.NET
<%@Assembly%> directive, 1066
Part Five - Web Applications and XML Web Services
<%@Page%> directive, 955
Chapter 18 - ASP.NET Web Pages and Web Controls
<%@WebService%> directive, 1066
Chapter 19 - ASP.NET Web Applications
Chapter<%Import%>20 - XMLdirective,Web Services955–956
Index
== operator, 378–379
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
A |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
C# language and then quickly moves to key technical and
A Programmer's Guide to ADO.NET in C# (Apress, 2002), 931 architectural issues for .NET developers.
abstract base classes
and interface support, 275
Tablevsof. interfaceContents, 276–277
C# and the .NET Platform, Second Edition abstract classes, defining, 215–216
Introduction
abstract keyword, 216
Part One - Introducing C# and the .NET Platform
abstract members, 273
Chapter 1 - The Philosophy of .NET
Chapabstracter 2 members,- Buildingdefined,C# Applications22
Part Two - The C# Programming Language
abstract methods, 216–220
Chapter 3 - C# Language Fundamentals abstract stream class, 818–822
Chapter 4 - Object-Oriented Programming with C#
BufferedStreams,822
Chapter 5 - Exceptions and Object Lifetime
FileStreams,820
Chapter 6 - Interfaces and Collections
members of, 819
Chapter 7 - Callback Interfaces, Delegates, and Events
MemoryStreams,820–821
Chapter 8 - Advanced C# Type Construction Techniques
Access databases, connecting to, 891
Part Three - Programming with .NET Assemblies
Access, Microsoft, 886
Chapter 9 - Understanding .NET Assemblies
Chapteraccess10modifiers,- Processes,method,AppDomains,140–143Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming accessibility keywords, 141
Part Four - Leveraging the .NET Libraries
accessor methods and object fields, 563
Chapter 12 - Object Serialization and the .NET Remoting Layer
Activate event, 641–642
Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapteractivation14 URLs,- A Better571Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls activator class, 518–520
Chapter 16 - The System.IO Namespace
Activator.GetObject() method, 571
Chapter 17 - Data Access with ADO.NET
active colors, establishing, 692–694
Part Five - Web Applications and XML Web Services
color type members, 693
Chapter 18 - ASP.NET Web Pages and Web Controls
ColorDialog class, 693–694
Chapter 19 - ASP.NET Web Applications
ChapterActive Server20 - XMLPagesW b(ASP)Services
building classic, 947–950
Index
page composition, 968–969
List of Figures
page derivation, 970–971
List of Tables
page life-cycle, 978–982 error events, 979–981
IsPostBack property, 981–982 problems with classic, 950
ad hoc polymorphism, 189–191
Add Class Wizard, 225–228
Add Member Wizard, 228
Add References dialog box, 68,408,449
Add Web Reference, VS .NET
utility,1095
wizard,1063
administration utility, .NET, 447–448
ADO.NET, data access with, 843–931
vs. ADO, 843–844
C# and the .NET Platform, Second Edition
ADO.NET namespaces, 850–851
by Andrew Troelsen |
ISBN:1590590554 |
CommandBuilder types and SQL Commands, 912–914 |
|
Apress © 2003 (1200 pages)
connected layer of ADO.NET, 888–893
This comprehensive text starts with a brief overview of the
Access databases, connecting to, 891
C# language and then quickly moves to key technical and core OLE DB providers, 889
architectural issues for .NET developers. database schema information, obtaining with, 891–892
defined,844
OleDbConnection type members, 890
Table of Contents
SQL commands, building with OleDbCommand, 892–893
C# and the .NET Platform, Second Edition
data providers, 845–850
Introduction
IDataAdapter interface, 848
Part One - Introducing C# and the .NET Platform
IDataParameter interface, 846–847
Chapter 1 - The Philosophy of .NET
IDataReader interface, 848–850
Chapter 2 - Building C# Applications
IDataRecord interface, 848–850
Part Two - The C# Programming Language
IDbCommand interface, 846–847
Chapter 3 - C# Language Fundamentals
IDbConnection and IDbTransaction interfaces, 846
Chapter 4 - Object-Oriented Programming with C#
IDbDataAdapter interface, 848
Chapter 5 - Exceptions and Object Lifetime
IDbDataParameter interface, 846–847
Chapter 6 - Interfaces and Collections
selecting,887
ChapterDataColumn7 - Callbacktype,Interfaces,852–858Delegates, and Events
Chapter adding8 - Advancedto DataTable,C# Type855Construction Techniques
Part Threeauto- Programming-incrementingwithfields,.NETenabling,Assemblies856–857
Chapter building9 - UnderstandingDataColumn,.NET854Assembli–855es
Chapter configuring10 - Processes,as primaryAppDomains,key constraint,Contexts,855and Threads
XML data representation, configuring, 857–858
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
DataRelation type, 879–883
Part Four - Leveraging the .NET Libraries
properties of, 880
Chapter 12 - Object Serialization and the .NET Remoting Layer
related tables navigation, 880–883
Chapter 13 - Building a Better Window (Introducing Windows Forms)
DataRow type, 858–861
Chapter 14 - A Better Painting Framework (GDI+)
DataSet type, 874–879
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
DataSets at design time, 927–931
Part Five - Web Applications and XML Web Services
typed DataSets at design time, 928–929
Chapter 18 - ASP.NET Web Pages and Web Controls typed DataSets, defined, 927
Chapter 19 - ASP.NET Web Applications
typed DataSets, structure of, 929–931
Chapter 20 - XML Web Services
untyped DataSets, defined, 927
Index
DataTable, building, 863–871
List of Figuresfilters and sort orders, 867–869
List of Tablesrows, deleting, 866–867 rows, updating, 869–871
DataTable type, 861–863
DataView type, 871–873
disconnected layer of ADO.NET, 844,901–905 libraries,844
multitabled DataSets, filling, 916–919 need for ADO.NET, 843–844 OleDbCommand
executing stored procedures with, 899–901
inserting, updating and deleting records with, 897–899 OleDbDataAdapter type, 901–905
column names, altering with, 904–905 core members of, 903
DataSets, filling with, 903–904
OleDbDataReader,894–896
Command Behavior, specifying, 895–896
C# and the .NET Platform, Second Edition multiple result sets, obtaining with, 896
by Andrew Troelsen |
ISBN:1590590554 |
schema information, obtaining with, 896 |
|
Apress © 2003 (1200 pages) |
|
simple test database, building, 886 |
|
This comprehensive text starts with a brief overview of the
SQL Data Provider, 906–912
C# language and then quickly moves to key technical and
SqlDataAdapter, inserting records with, 907–910 architectural issues for .NET developers.
SqlDataAdapter, updating records with, 910–912
System.Data.SQLTypes namespace, 907
System.Data namespace, 851–852
Table of Contents
System.Data.OleDb namespace, 888
C# and the .NET Platform, Second Edition
VS .NET wizards. Seewizards
Introduction
Windows Forms example, 914–916
Part One - Introducing C# and the .NET Platform
XML-based DataSets, reading and writing, 883–885
Chapter 1 - The Philosophy of .NET
adornments, member, 22
Chapter 2 - Building C# Applications
PartAdRotatorTwo - Thecontrol,C# Programming996–997 Language
Chapter 3 - C# Language Fundamentals
Advanced .NET Remoting (Apress, 2002), 560
Chapter 4 - Object-Oriented Programming with C# alert() method, 945
Chapter 5 - Exceptions and Object Lifetime
al.exe (assembly linker), 424
Chapter 6 - Interfaces and Collections
Chaptaliasesr 7(C#)- Callback Interfaces, Delegates, and Events
Chaptdefiningr 8 - namespace,Advanced C#174Type Construction Techniques
Part systemThree - Programmingdata types and,with122.NET–128Assemblies
basic numerical members, 125–126
Chapter 9 - Understanding .NET Assemblies
experimenting with, 125
Chapter 10 - Processes, AppDomains, Contexts, and Threads
string data, parsing values from, 127–128
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
System.Boolean members, 126
Part Four - Leveraging the .NET Libraries
System.CharNext members, 127
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapteranchoring13 -behavior,Building aconfiguring,Better Window779(Introducing–780 Windows Forms)
ChapterAnchorStyles14 - Better Painting Framework (GDI+)
values, 779
Chapter 15 - Programming with Windows Forms Controls apartment structure, COM, 463,479–480
Chapter 16 - The System.IO Namespace
app.config file, 428–429
Chapter 17 - Data Access with ADO.NET
PartAppDomainsFive - Web(SystemApplications.AppDomainand XMLtype),Web Services462–468
AppDomainManipulator.exe process, 467–468
Chapter 18 - ASP.NET Web Pages and Web Controls
basics,462–463
Chapter 19 - ASP.NET Web Applications
context, process and thread relationship to, 474–475
Chapter 20 - XML Web Services
creating programmatically, 466–467
Index
events of, 464
List of Figures
interacting programmatically with, 465–466
List of Tables members of, 464
unloading programmatically, 468
AppendText() method, 818
Apple OSX, 16
applications
applicationand system-level exceptions, 252 application cache, 1037–1043
*.aspx file, modifying, 1041–1043 data caching example, 1038–1040
Application class. SeeSystem.Windows.Forms.Application class application domains, 262,554
application-level exceptions, building custom, 243–247 application roots, 259
application states vs. session states, 1033–1037 application data, modifying, 1036–1037
application-level state data, maintaining, 1033–1036
C# and the .NET Platform, Second Edition
Web application shutdown, 1037
by Andrew Troelsen |
ISBN:1590590554 |
Application_Error() event handler, 1031–1032 |
|
Apress © 2003 (1200 pages) |
|
ApplicationExit event, 619 |
|
This comprehensive text starts with a brief overview of the
Application.Run() method, 641
C# language and then quickly moves to key technical and
Application_Start() event handler, 1038,1040 architectural issues for .NET developers.
<appSettings>, custom Web settings with, 1057
arguments, method, 325
Table of Contents
arrays
C# and the .NET Platform, Second Edition
ArrayList class type, 310,311–312
Introduction jagged,157
Part One - Introducing C# and the .NET Platform
manipulation in C#, 154–159
Chapter 1 - The Philosophy of .NET
arrays as parameters and return values, 155–156
Chapter 2 - Building C# Applications multidimensional arrays, 156–157
Part Two - The C# Programming Language
System.Array base class, 158–159
Chapter 3 - C# Language Fundamentals rectangular,156
Chapter 4 - Object-Oriented Programming with C# as keyword, 278
Chapter 5 - Exceptions and Object Lifetime
as operator, 140
Chapter 6 - Interfaces and Collections
Chapterascending7 -valuesCallback(fontInterfaces,metrics),Delegates,697 and Events
Chapter 8 - Advanced C# Type Construction Techniques
aspect-oriented programming, 523
Part Three - Programming with .NET Assemblies
ASP.NET IDE Web Matrix, 90
Chapter 9 - Understanding .NET Assemblies
ASP.NET Web applications, 1023–1058
Chapter 10 - Processes, AppDomains, Contexts, and Threads
application cache, 1037–1043
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
*.aspx file, modifying, 1041–1043
Part Four - Leveraging the .NET Libraries
data caching example, 1038–1040
Chapter 12 - Object Serialization and the .NET Remoting Layer
application states vs. session states, 1033–1037
Chapter 13 - Building a Better Window (Introducing Windows Forms) application data, modifying, 1036–1037
Chapter 14 - A Better Painting Framework (GDI+) application-level state data, maintaining, 1033–1036
Chapter 15 - Programming with Windows Forms Controls
Web application shutdown, 1037
Chapter 16 - The System.IO Namespace configuration inheritance, 1057–1058
Chapter 17 - Data Access with ADO.NET configuring with web.config file, 1050–1057
Part Five - Web Applications and XML Web Services
custom Web settings with <appSettings>, 1057
Chapter 18 - ASP.NET Web Pages and Web Controls elements of web.config, 1052
Chapter 19 - ASP.NET Web Applications
error output, customizing with <customErrors>, 1053–1054 Chapter storing20 - XMLstateWebwithServices<sessionState>, 1054–1056
Index tracing with <trace>, 1052–1053
List ofcookies,Figures1047–1050
List of Tablescreating,1047–1049
reading incoming data, 1049–1050 Global.asax file, 1030–1032
exception event handler, 1031–1032 HttpApplication base class, 1032
session data, maintaining, 1043–1046 state management, 1023–1026
view state, 1026–1029
custom view state data, 1029 definition and basics, 1026 demonstrating,1027–1029
ASP.NET Web pages, 935–1020 benefits of ASP.NET, 950–951
BetterAspNetCarApp Web application, coding, 966–968 classic Active Server Page
building,947–950
problems with, 950
C# and the .NET Platform, Second Edition |
|
client-side scripting, 943–946 |
ISBN:1590590554 |
by Andrew Troelsen |
|
default.htm form data, 946 |
|
Apress © 2003 (1200 pages) |
|
example,945–946 |
|
This comprehensive text starts with a brief overview of the compilation cycle, 958–961
C# language and then quickly moves to key technical and debugging and tracing, 1020
architectural issues for .NET developers. form data, submitting, 947
GDI+ on Web server, 1016–1019
GET and POST methods, 947
Table of Contents
HTML (Hypertext Markup Language)
C# and the .NET Platform, Second Edition
controls,1014–1016
Introduction
document structure, 939–940
Part One - Introducing C# and the .NET Platform
form development, 940–943
Chapter 1 - The Philosophy of .NET
HTTP requests, interacting with incoming, 971–975
Chapter 2 - Building C# Applications
browser statistics, 973
Part Two - The C# Programming Language
form data, access to incoming, 975
Chapter 3 - C# Language Fundamentals
HttpRequest type members, 972
Chapter 4 - Object-Oriented Programming with C# server variables, access to, 974
Chapter 5 - Exceptions and Object Lifetime
HTTP responses, interacting with outgoing, 975–978
Chapter 6 - Interfaces and Collections
HTML content, emitting, 977
Chapter HttpResponse7 - Callback Interfaces,type propertiesDel gates,and methods,and Events976
Chapter redirecting8 - Advancedusers,C#977Type–978Construction Techniques
Part HTTP,Three -roleProgrammingof, 935–936with .NET Assemblies
Chapternamespaces,9 - Understanding952–953 .NET Assemblies
Chapterpage10composition,- Processes, 968AppDoma–969 ins, Contexts, and Threads
page derivation, 970–971
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
page life-cycle, 978–982
Part Four - Leveraging the .NET Libraries
error events, 979–981
Chapter 12 - Object Serialization and the .NET Remoting Layer
IsPostBack property, 981–982
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Web application, creating manually, 953–958
Chapter 14 - A Better Painting Framework (GDI+)
*.aspx file, coding, 954–958
Chapter 15 - Programming with Windows Forms Controls
<%@Page%> directive, 955
Chapter 16 - The System.IO Namespace
<%Import%> directive, 955–956
Chapter 17 - Data Access with ADO.NET script blocks, 956–957
Part Five - Web Applications and XML Web Services
widget declarations, 957–958
Chapter 18 - ASP.NET Web Pages and Web Controls
Web application, creating with VS .NET, 961–966
Chapter 19 - ASP.NET Web Applications
code behind file, 965–966
Chapter 20 - XML Web Services
initial *.aspx file, 964–965
Index
Web applications and Web servers, 936–938
List of Figures
Web controls. SeeWeb controls,ASP.NET
List of Tables
aspnet_regiis.exe command line tool, 937
*.aspx file
application cache and, 1041–1043 coding,954–958
examining structure of, 964–965
assemblies, .NET
assemblyand modulelevel attributes, 526–527 <%@Assembly%> directive, 1066
assembly manifest, 17–18,397,400,415 assembly metadata, viewing, 37–38 AssemblyInfo.cs file (VS .NET), 527 AssemblyLoad() method, 511–512 AssemblyName type, 513 AssemblyRef #n tokens, 503
binding *.resources file into, 736–737
C# client application, 408–409
CarLibrary C# and the .NET Platform, Second Edition |
ISBN:1590590554 |
||
|
by Andrew Troelsen |
||
manifest,415–417 |
|
||
|
Apress © 2003 (1200 pages) |
|
|
types,418–419 |
|
||
|
|
|
|
This comprehensive text starts with a brief overview of the classic COM binaries, problems with, 395–397
C# language and then quickly moves to key technical and
COM deployment, 396–397
architectural issues for .NET developers.
COM versioning, 396 client,567
<codebase> elements, 442–444
Table of Contents
cross-language inheritance, 411–415
C# and the .NET Platform, Second Edition
custom version policies, 440
Introduction
delayed signing, 434–435
Part One - Introducing C# and the .NET Platform
documenting defining assembly, 502–503
Chapter 1 - The Philosophy of .NET
GAC internals, 440–442
Chapter 2 - Building C# Applications machine-wide configuration file, 445–446
Part Two - The C# Programming Language
multifile assembly, building, 419–422
Chapter 3 - C# Language Fundamentals airvehicles.dll,422
Chapter 4 - Object-Oriented Programming with C# ufo.netmodule,421–422
Chapter 5 - Exceptions and Object Lifetime multifile assembly, using, 422–424
Chapter 6 - Interfaces and Collections
.NET administrative tool, 447–448
Chapterngen7.exe- Callbackutility, 448Interfaces,–449 Delegates, and Events
Chapteroverview8 - Advancedof, 10–11C#,397Type–404Construction Techniques
Part Threecode- Preuse,ogramming402 with .NET Assemblies
Chapter physical9 - Understandlogicalng .views,NET Assemblies401–402
Chapter security10 - Procontextess s, AppDomains,defined, 404 Contexts, and Threads
side-by-side execution, 404
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
single file and multifile assemblies, 400–401
Part Four - Leveraging the .NET Libraries
type boundaries, 403
Chapter 12 - Object Serialization and the .NET Remoting Layer
versionable and self-describing entities, 403
Chapter 13 - Building a Better Window (Introducing Windows Forms)
private assemblies
Chapter 14 - A Better Painting Framework (GDI+)
probing for, 425–426,429–430
Chapter 15 - Programming with Windows Forms Controls
understanding,425
Chapter 16 - The System.IO Namespace
and XML configuration files, 426–429
Chapter 17 - Data Access with ADO.NET publisher policy assemblies, 444–445
Part Five - Web Applications and XML Web Services
referenced, documenting, 503
Chapter 18 - ASP.NET Web Pages and Web Controls referencing multiple external (csc.exe), 50
Chapter 19 - ASP.NET Web Applications server,567
Chapter 20 - XML Web Services shared assemblies
Index building,432–434
List of Figures
installing and removing, 435–436
List of TablesSharedAssembly version 2.0.0.0, 438–439 understanding,430–431
using,436 versioning,437–438
single file
and multifile, 13,400–401 strong names, 431–432
System.Configuration namespace, 446–447 VB .NET client application, 409–411 viewing compiled, 1068–1069
VS .NET Add References dialog box, 449
asynchronous delegates, 341–347 callbacks for, 344–347
invoking methods asynchronously, 343–344
asynchronous IO, 833
asynchronous method invocations, 343–344,1090–1091,1093–1094
C# and the .NET Platform, Second Edition
asynchronous remoting, 603–604 |
ISBN:1590590554 |
|||
|
by Andrew Troelsen |
|||
attributed programming,Apress ©52020 3–(152200 pages) |
|
|||
|
|
|
|
|
attributes |
This comprehensive text starts with a brief overview of the |
|||
@Page,955 |
C# language and then quickly moves to key technical and |
|||
|
architectural issues for .NET developers. |
|
assemblyand modulelevel, 526–527 assembly-level,527
AttributeUsageAttribute,525
Table of Contents
AutoGenerateColumns attribute, 999
C# and the .NET Platform, Second Edition
building custom, 523–524
Introduction
Inherits attribute, 968
Part One - Introducing C# and the .NET Platform
and methods, defined, 179
Chapter 1 - The Philosophy of .NET
predefined system, 521
Chapter 2 - Building C# Applications
restricting usage, 524–525
Part Two - The C# Programming Language
at runtime, 528
Chapter 3 - C# Language Fundamentals
shorthand notation, 524
Chapter 4 - Object-Oriented Programming with C#
[WebMethod] attribute, 1066
Chapter 5 - Exceptions and Object Lifetime
[WebService] attribute, 1077–1078
Chapter 6 - Interfaces and Collections
auto-generating SQL Commands with CommandBuilder types, 912–914
Chapter 7 - Callback Interfaces, Delegates, and Events
auto-incrementing fields, enabling (DataColumns), 856–857
Chapter 8 - Advanced C# Type Construction Techniques
PartAutoFlushThree - property,Pr gramming824 with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
AutoGenerateColumns attribute, 999
Chapter 10 - Processes, AppDomains, Contexts, and Threads
AutoPostBack property, 984–985
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
AutoScroll properties, 636–637
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
B |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
base class |
C# language and then quickly moves to key technical and |
|
architectural issues for .NET developers. |
|
creation,203–204
libraries, .NET, 7–8,32,76,197
Tablebaseofinterfaces,Contentsmultiple, 287–288
C# and the .NET Platform, Second Edition
base keyword, 204,215
Introduction
BeginEdit() method (DataTables), 870
Part One - Introducing C# and the .NET Platform
BeginInvoke() method, 343–345
Chapter 1 - The Philosophy of .NET
ChapterBeginRead()2 - Buildingand BeginWrite()C# Applicationsmethods, 833
Part Two - The C# Programming Language
BeginTransaction() method, 846
Chapter 3 - C# Language Fundamentals
\bin directory, 967–968
Chapter 4 - Object-Oriented Programming with C#
binaries
Chapter 5 - Exceptions and Object Lifetime
binary formatter (serialization), 545–547
Chapter 6 - Interfaces and Collections
binary reuse, 402
Chapter 7 - Callback Interfaces, Delegates, and Events
BinaryReaders and BinaryWriters, 829–831
Chapter 8 - Advanced C# Type Construction Techniques classic COM, 395–397
Part Three - Programming with .NET Assemblies
overview of, 11–13
Chapter 9 - Understanding .NET Assemblies
<binding> element (WSDL), 1082
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapterbitmaps11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part BitmapFour - Leveragingtype, 721–the723.NET Libraries
Chapteras brushes,12 - Object717Serialization and the .NET Remoting Layer
Chapter 13 |
- Building Better Window (Introducing Windows Forms) |
black box programming, 192 |
|
Chapter 14 |
- A Better Painting Framework (GDI+) |
BlinkStyle properties, 778 |
|
Chapter 15 |
- Programming with Windows Forms Controls |
BorderStyle property, 781 |
|
Chapter 16 |
- The System.IO Namespace |
boxing and unboxing, 128–132
Chapter 17 - Data Access with ADO.NET
(un)boxing examples, 129–130
Part Five - Web Applications and XML Web Services
(un)boxing custom structures, 170–171
Chapter 18 - ASP.NET Web Pages and Web Controls
underlying CIL, 131–132
Chapter 19 - ASP.NET Web Applications
Chapterbreakpoints,20 - XML71 Web Services
Index
browsers
List of Figures
Browser property, 973
List ofstatistics,Tables obtaining, 973
brushes
bitmaps as, 717 gradient,719–720 hatch style, 715–717 solid,713–715 textured,717–718
BSD Unix, 16
BufferedStreams,822
bug reports, generating, 52–53
bugs, errors, exceptions defined, 231–232
bundling external resources, 732–733
Button type, 752–755
ButtonBase properties, 753
content position, configuring, 753
C# and the .NET Platform, Second Edition default input, 767
by Andrew Troelsen |
ISBN:1590590554 |
example,754–755 |
|
Apress © 2003 (1200 pages) |
|
tool bar buttons, 663–664 |
|
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
C |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
C# language and then quickly moves to key technical and
C# applications, building, 43–90
architectural issues for .NET developers. bug reports, generating, 52–53
building .NET applications with other IDEs, 89–90
compiler options, 54–55
Table of Contents
cordbg.exe (command line debugger), 55–57
C# and the .NET Platform, Second Edition
with csc.exe
Introduction
compiling multiple source files, 49–50
Part One - Introducing C# and the .NET Platform
output options, 46
Chapter 1 - The Philosophy of .NET referencing external assemblies, 48–50
Chapter 2 - Building C# Applications csc.exe (C# compiler)
Part Two - The C# Programming Language
configuring,44–45
Chapter 3 - C# Language Fundamentals
configuring other .NET command line tools, 45
Chapter 4 - Object-Oriented Programming with C# response files, 50–52
Chapter 5 - Exceptions and Object Lifetime debugging with Visual Studio .NET IDE, 70–71
Chapter 6 - Interfaces and Collections documenting source code via XML, 76–82
Chapter viewing7 - CallbackgeneratedInterfaces,XML file,D legates,79–81 and Events
Chapter VS8 -.NETAdvanceddocumentationC# Type Constructionsupport, 81–Tec82hniques
Part ThreeXML- Programmingtags, 77 with .NET Assemblies
Chapterpreprocessor9 - Understanddirectives,ng .NET82–Assemblies88
Chapter altering10 - Processes,line numbers,AppDomains,87–88 Contexts, and Threads
conditional code compilation, 84–86
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
issuing warnings and errors, 86
Part Four - Leveraging the .NET Libraries
specifying code regions, 83–84
Chapter 12 - Object Serialization and the .NET Remoting Layer
System.Environment class, 88–89
Chapter 13 - Building a Better Window (Introducing Windows Forms)
VS .NET IDE, 57–61,71–76
Chapter 14 - A Better Painting Framework (GDI+)
database manipulation tools, 73–74
Chapter 15 - Programming with Windows Forms Controls
debugging applications with, 70–71
Chapter 16 - The System.IO Namespace integrated help, 74–76
Chapter 17 - Data Access with ADO.NET object browser utility, 73
Part Five - Web Applications and XML Web Services
project solution, creating, 60–61
Chapter 18 - ASP.NET Web Pages and Web Controls server explorer window, 71–72
Chapter 19 - ASP.NET Web Applications start page, 58–59
Chapter 20 - XML Web Services
XML-related editing tools, 72–73
Index
VS .NET test application, building, 61–70
List of Figures
adding code, 67
List of Tablesconfiguring a C# project, 64–65 inserting new C# type definitions, 68–69 outlining code via VS .NET, 69–70 properties window, 66
referencing external assemblies via VS .NET, 67–68 solution explorer window, 62–64
C# language, 93–177
array manipulation in C#, 154–159
arrays as parameters and return values, 155–156 multidimensional arrays, 156–157
System.Array base class, 158–159 basic C# class, anatomy of, 93–97
Main() method, variations on, 94–95 processing command line parameters, 95–96
simulating command arguments with VS .NET, 96–97 boxing and unboxing, 128–132
(un)boxing examples, 129–130
C# and the .NET Platform, Second Edition underlying CIL, 131–132
C# type |
by Andrew Troelsen |
ISBN:1590590554 |
|
|
Apress © 2003 (1200 pages)
advanced construction techniques. Seeconstruction techniques, advanced C# type
This comprehensive text starts with a brief overview of the definitions, inserting, 68–69
C# language and then quickly moves to key technical and class defined, 179–184
architectural issues for .NET developers. method overloading, 181–182
self-reference in C#, 183–184
client application, 408–409
Table of Contents
compiler (csc.exe). Seecsc.exe (C# compiler)
C# and the .NET Platform, Second Edition
compiler options, 54–55
Introduction
composition of C# applications, 100–101
Part One - Introducing C# and the .NET Platform
configuring a project, 64–65
Chapter 1 - The Philosophy of .NET
console class, input and output with, 105–109
Chapter 2 - Building C# Applications formatting textual output, 106–107
Part Two - The C# Programming Language
string formatting flags, 107–109
Chapter 3 - C# Language Fundamentals control flow constructs, 137–139
Chapter 4 - Object-Oriented Programming with C# core project workspace types, 60–61
Chapter 5 - Exceptions and Object Lifetime custom class methods, defining, 140–143
Chapter 6 - Interfaces and Collections
accessibility keywords, 141
Chapter method7 - Callbaaccessk Interfaces,modifiers,Delegates,141–143and Events
Chaptercustom8 -namespaces,Advanced C# Typedefining,Construction171–176Techniques
Part Threedefault- Programmingnamespacewithof VS.NET.NET,Assemblies175–176
Chapter namespace9 - Understaliases,nding .NETdefining,Assemblies174
Chapter nested10 - Processes,namespaces,AppDomains,174–175Contexts, and Threads
resolving name clashes, 173–174
Chapter 11 - Type Refl ction, Late Binding, and Attribute-Based Programming
default assignments and variable scope, 102–104
Part Four - Leveraging the .NET Libraries
enumerations,164–168
Chapter 12 - Object Serialization and the .NET Remoting Layer
EmpType enumeration, 164
Chapter 13 - Building a Better Window (Introducing Windows Forms)
System.Enum base class, 166–168
Chapter 14 - A Better Painting Framework (GDI+)
features and advantages of, 8–9
Chapter 15 - Programming with Windows Forms Controls
indexer from VB .NET, 374–375
Chapter 16 - The System.IO Namespace interfaces, defining with, 273–277
Chapter 17 - Data Access with ADO.NET iteration constructs, 134–137
Part Five - Web Applications and XML Web Services
foreach/in loop, 135–136
Chapter 18 - ASP.NET Web Pages and Web Controls for loop, 135
Chapter 19 - ASP.NET Web Applications
while and do/while looping constructs, 136–137
Chapter 20 - XML Web Services
keywords, summary of, 367–369
Index
member variable initialization syntax, 104–105
List of Figures
method parameter modifiers, 147–154
List of Tablesdefault parameter passing behavior, 148 out keyword, 148–149
params keyword, 150–151
passing reference types by reference and value, 152–154 ref keyword, 149–150
object construction basics, 97–100 operators,139–140
pointer-centric operators. Seepointer-centric operators program constants, defining, 132–134
snap-in, building, 531 static methods, 143–147
defining,143–145
static data, defining, 145–147 string manipulation in C#, 160–164
escape characters and verbatimstrings,161–162 System.Text.StringBuilder,162–164
structures, defining in C#, 168–171
C# and the .NET Platform, Second Edition system data types and C# aliases, 122–128
by Andrew Troelsen |
ISBN:1590590554 |
basic numerical members, 125–126 |
|
Apress © 2003 (1200 pages) |
|
experimenting with, 125 |
|
This comprehensive text starts with a brief overview of the string data, parsing values from, 127–128
C# language and then quickly moves to key technical and
System.Boolean members, 126
architectural issues for .NET developers.
System.CharNext members, 127
System.Object base class, 115–122
default behaviors, overriding, 118–119
Table of Contents
Equals(), overriding, 119–120
C# and the .NET Platform, Second Edition
GetHashCode(), overriding, 120–122
Introduction
static members of, 122
Part One - Introducing C# and the .NET Platform
ToString(), overriding, 119
Chapter 1 - The Philosophy of .NET using keyword, 31–32
Chapter 2 - Building C# Applications
value-based and reference-based types, 109–114
Part Two - The C# Programming Language
comparison of, 113–114
Chapter 3 - C# Language Fundamentals
value types containing reference types, 112–113
Chapter 4 - Object-Oriented Programming with C#
C/Win32 API programming, 3–4
Chapter 5 - Exceptions and Object Lifetime
C++/MFC programming, 4,409
Chapter 6 - Interfaces and Collections
Chcache,pter 7application,- C llback1037Interfaces,–1043 Delegates, and Events
Chapter*.aspx8 file,- Advancedmodifying,C# 1041Type–Construction1043 Techniques
Part dataThreecaching- Programmingexample,with1038.NET–1040Assemblies
Chapter 9 - Understanding .NET Assemblies
Cache class, 1038
Chapter 10 - Processes, AppDomains, Contexts, and Threads
CacheDependency type, 1040
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Calculator XML Web Service, 1093
Part Four - Leveraging the .NET Libraries
ChCalcWSpter 12Web- Objectmethods,Serializationinvoking,and1071the –.NET1072Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms) calendar control, 995–996
Chapter 14 - A Better Painting Framework (GDI+) callbacks
Chapter 15 - Programming with Windows Forms Controls for asynchronous delegates, 344–347
Chapter 16 - The System.IO Namespace functions, defined, 325
Chapter 17 - Data Access with ADO.NET instance methods as, 339–341
Part Five - Web Applications and XML Web Services
interfaces,321–325
Chapter 18 - ASP.NET Web Pages and Web Controls
CancelEdit() method (DataTables), 870
Chapter 19 - ASP.NET Web Applications
CAO (client-activated objects)
Chapter 20 - XML Web Services
defined,564
Index
understanding,587–589
List of Figures
CAO/WKO-singleton objects, 589–595
List of Tables
client-side lease adjustment, 595
default leasing behavior/characteristics, 590–594 server-side lease adjustment, 594–595
caps, pen, 711–713
Car project
Car type, viewing for, 501–502
Car.CarDelegate, multicasting with, 338–339
CarControl,792–796
CarControl type, testing, 797–798 custom events, defining, 794 custom properties, defining, 794–796
CarDelegate, using, 334–337
CarLibrary
manifest,415–417 types,418–419
CarLogApp project, 834–837
C# and the .NET Platform, Second Edition
Cars General Assembly, building, 583–584
by Andrew Troelsen |
ISBN:1590590554 |
Cars Indexer, variation of, 372–373 |
|
Apress © 2003 (1200 pages) |
|
CarSalesInfoWS project, updating, 1100–1102 |
|
This comprehensive text starts with a brief overview of the
CarService, installing, 601
C# language and then quickly moves to key technical and casting architectural issues for .NET developers.
between class types, 222–225 determiningtype of employee, 223–224
Table ofnumericalContents casts, 224–225
C# andexplicit,the .277NET–Platform,278 Second Edition
Introduction
catch statements, generic, 249
Part One - Introducing C# and the .NET Platform
catching exceptions, 236–240
Chapter 1 - The Philosophy of .NET
HelpLink property, 239–240
Chapter 2 - Building C# Applications
StackTrace property, 239
Part Two - The C# Programming Language
TargetSite property, 238–239
Chapter 3 - C# Language Fundamentals
channels (.NET Remoting), 558
Chapter 4 - Object-Oriented Programming with C#
ChannelServices type, 572–573
Chapter 5 - Exceptions and Object Lifetime
ChapterCheckBoxes,6 - Interfaces755–756and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events checked keyword, 356–358
Chapter 8 - Advanced C# Type Construction Techniques
CheckedListBox Control, 758–760
Part Three - Programming with .NET Assemblies
child Form, building (MDI applications), 668
Chapter 9 - Understanding .NET Assemblies
Chapterchild windows10 - Processes,(MDI applications),AppDomains,668Contexts,–669 and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
CIL (Common Intermediate Language)
Part Four - Leveraging the .NET Libraries
code,12,397,399
Chapter 12 - Object Serialization and the .NET Remoting Layer compiling to platform-specific instructions, 18
Chapter 13 - Building a Better Window (Introducing Windows Forms) ofnew keyword, 257–259
Chapterrole14and- AbenefitsBetter Paintingof, 13–16Framework (GDI+)
Chaptertokens,15 -manifest,Programming417 with Windows Forms Controls
Chapter 16 - The System.IO Namespace
classes
Chapter 17 - Data Access with ADO.NET
ASP.NET-generated class names, 961
Part Five - Web Applications and XML Web Services
Class Library node of MSDN library, 76
Chapter 18 - ASP.NET Web Pages and Web Controls
Class Viewer Web application, 38
ChapterCTS19class- ASPtypes,.NET Web19 Applications
Chaptdefined,r 20 -97XML,789Web Services
Indexgenerating class definitions with VS .NET, 225–229
List of FiguresAdd Class Wizard, 225–228
adding members to types, 228–229
List of Tables
System.Collections, class types of, 310–314
classic COM binaries, problems with, 395–397 COM deployment, 396–397
COM versioning, 396
classical inheritance, 188
classical polymorphism, 189–191
ClassicAspPage.asp file, 947
CLI (Common Language Infrastructure), 25,40
client applications C#,408–409
VB .NET, 409–411
client area, invalidating (paint sessions), 682
client assembly
building (MBV), 585–587
defined,567 C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
client, defined, 554 |
|
Apress © 2003 (1200 pages) |
|
client-side *.config files, building, 581–582
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and client-side lease adjustment, 595
architectural issues for .NET developers. client-side scripting, 943–946
default.htm form data, 946
Tableexample,of Contents945–946
C# and the .NET Platform, Second Edition
ClientValidationFunction property, 1012
Introduction
cloneable objects, building, 297–302
Part One - Introducing C# and the .NET Platform
Close() method, 895
Chapter 1 - The Philosophy of .NET
ChapterCloseFigure()2 - Buildingmethod,C# 730Applications
Part Two - The C# Programming Language
Closing and Closed events, 641–642
Chapter 3 - C# Language Fundamentals
CLR (common language runtime)
Chapter 4 - Object-Oriented Programming with C# defined,7
Chapter 5 - Exceptions and Object Lifetime header,397–399
Chapter 6 - Interfaces and Collections system-level exceptions, 240–242
Chapter 7 - Callback Interfaces, Delegates, and Events understanding,25–27
Chapter 8 - Advanced C# Type Construction Techniques
CLS (Common Language Specification), 23–25
Part Three - Programming with .NET Assemblies
CLSCompliant attribute, 526
Chapter 9 - Understanding .NET Assemblies defined,7
Chapter 10 - Processes, AppDomains, Contexts, and Threads ensuring compliance, 25
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
code
Part Four - Leveraging the .NET Libraries
code behind file, examining (Car project), 965–966
Chapter 12 - Object Serialization and the .NET Remoting Layer code behind technique, 935,951,953
Chapter 13 - Building a Better Window (Introducing Windows Forms)
<codebase> elements, 442–444
Chapter 14 - A Better Painting Framework (GDI+)
CodeBehind attribute, 965
Chapter 15 - Programming with Windows Forms Controls conditional compilation, 84–86
Chapter 16 - The System.IO Namespace libraries,28
Chapter 17 - Data Access with ADO.NET outlining via VS .NET, 69–70
Part Five - Web Applications and XML Web Services
regions, specifying, 83–84
Chapter 18 - ASP.NET Web Pages and Web Controls
reuse,402
Chapter 19 - ASP.NET Web Applications
collections.SeeSystem.Collections namespace
Chapter 20 - XML Web Services
Color types, 692–694
Index
ColorDialog class, 693–694
List of Figures
Listcolumnof Tablesnames
altering (DataGrids), 998–1000
altering with OleDbDataAdapter type, 904–905
ColumnMapping property, 857
COM (Component Object Model) apartment structure, 463,479–480 binaries, classic, 395–397 callback interfaces and, 321–322 COM AppID, 431
COM+ programming, 471 deployment,396–397 fundamentals of, 5–6 IDispatch reference, 517
IDL (Interface Definition Language), 499–500 interface pointers and, 273
interface using IDL attributes, 520–521
C# and the .NET Platform, Second Edition lollipop notation, 276
by Andrew Troelsen ISBN:1590590554 versioning,396
Apress © 2003 (1200 pages)
Combine(), static, 329,332,339
This comprehensive text starts with a brief overview of the ComboBoxes andC#ListBoxes,language761and–then763 quickly moves to key technical and
architectural issues for .NET developers. comma-delimited lists, 50
command arguments, simulating with VS .NET, 96–97
Table of Contents
Command Behavior, specifying Data Reader's, 895–896
C# and the .NET Platform, Second Edition
command line debugger (cordbg.exe). Seecordbg.exe (command line debugger)
Introduction
command line parameters, processing, 95–96
Part One - Introducing C# and the .NET Platform
ChapterCommandBehavior1 - T Philosophy.CloseConnection,of .NET 896
Chapter 2 - Building C# Applications
CommandBuilder types, auto-generating SQL Commands with, 912–914
Part Two - The C# Programming Language
CommandText property, 892
Chapter 3 - C# Language Fundamentals
CommandType property, 892
Chapter 4 - Object-Oriented Programming with C#
ChapterCommon5 Intermediate- Exceptions andLanguageObject Lifetime(CIL). SeeCIL(Common Intermediate Language)
Chapter 6 - Interfaces and Collections
common language runtime (CLR). SeeCLR(common language runtime)
Chapter 7 - Callback Interfaces, Delegates, and Events
Common Language Specification (CLS). SeeCLS(Common Language Specification)
Chapter 8 - Advanced C# Type Construction Techniques
Common Object Runtime Execution Engine, 26
Part Three - Programming with .NET Assemblies
ChapterCommon9 Type- UnderstandingSystem (CTS).NET. SeeAssembliesCTS(Common Type System)
Chapter 10 - Processes, AppDomains, Contexts, and Threads
CommonSnappableTypes.dll,530,532
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming comparable objects, building, 302–306
Part Four - Leveraging the .NET Libraries
custom properties and sort types, 306
Chapter 12 - Object Serialization and the .NET Remoting Layer multiple sort orders, 304–305
Chapter 13 - Building a Better Window (Introducing Windows Forms)
CompareTo() method, 302–303
Chapter 14 - A Better Painting Framework (GDI+)
comparison operators, overloading, 379–380
Chapter 15 - Progr mming with Windows Forms Controls
Chaptercompatibility16 - ThetextSystemstring,.IO403Namespace
Chapter 17 - Data Access with ADO.NET compilation cycle, ASP.NET, 958–961
Part Five - Web Applications and XML Web Services
compilers, .NET-aware, 12–13
Chapter 18 - ASP.NET Web Pages and Web Controls
compliance, CLS, 25
Chapter 19 - ASP.NET Web Applications
Chaptercomponents20 - XML Web Services
IndexComponent class, 622
List ofComponentFigures Services utility, 471
List ofdefined,Tables790
concurrency and thread synchronization, 475
conditional code compilation, 84–86
conditional operators, 138
configuration files machine-wide,445–446 and VS .NET, 428–429
configuration inheritance, 1057–1058
configuring a C# project, 64–65
connected layer, ADO.NET, 888–893 Access databases, connecting to, 891 core OLE DB providers, 889
database schema information, obtaining with, 891–892 defined,844
OleDbConnection type members, 890
C# and the .NET Platform, Second Edition |
|
SQL commands, building with OleDbCommand, 892–893 |
ISBN:1590590554 |
by Andrew Troelsen |
|
ConnectionString property, 921–922 |
|
Apress © 2003 (1200 pages) |
|
console class This comprehensive text starts with a brief overview of the Console types,C#824language and then quickly moves to key technical and
architectural issues for .NET developers. input and output with, 105–109
formatting textual output, 106–107
string formatting flags, 107–109
Table of Contents
const keyword, 200
C# and the .NET Platform, Second Edition
constant data, referencing across types, 134
Introduction
Partconstants,One - Introducingdefining program,C# nd the132.–NET134Platform
Chapter 1 - The Philosophy of .NET
construction techniques, advanced C# type, 355–392
Chapter 2 - Building C# Applications
+= and –+ operators, 385–386
Part Two - The C# Programming Language
C# indexer from VB .NET, 374–375
Chapter 3 - C# Language Fundamentals
C# keywords summary, 367–369
Chapter 4 - Object-Oriented Programming with C#
Cars Indexer variation, 372–373
Chapterchecked5 - Exceptionskeyword, 356and–Object358 Lifetime
Chaptercustom6 -conversionInterfaces androutinesCollections
Chapter creating,7 - Callback387–390Interfaces, Delegates, and Events
Chapter internal8 - Advancrepresentationd C# Typeof,Construction391–392 Techniques
Part customThree - Programmingindexer, building,with370.NET–372Assemblies
custom type conversions, 386–387
Chapter 9 - Understanding .NET Assemblies
implicit conversion routines, 390–391
Chapter 10 - Processes, AppDomains, Contexts, and Threads
overloadable operators, valid, 385
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
overloaded operators
Part Four - Leveraging the .NET Libraries
internal representation of, 380–383
Chapter 12 - Object Serialization and the .NET Remoting Layer
from overloaded-operator-challenged languages, 383–385
Chapter 13 - Building a Better Window (Introducing Windows Forms)
overloading operators, 375–380
Chapter 14 - A Better Painting Framework (GDI+) comparison operators, 379–380
Chapter 15 - Programming with Windows Forms Controls equality operators, 378–379
Chapter 16 - The System.IO Namespace sizeof keyword, 366–367
Chapter 17 - Data Access with ADO.NET type indexers, 373–374
Part Five - Web Applications and XML Web Services
unchecked keyword, 358–359
Chapter 18 - ASP.NET Web Pages and Web Controls
underflow conditions, 359
Chapter 19 - ASP.NET Web Applications
unsafe code, 359–366
Chapter 20 - XML Web Services
–> operator, 364
Index * and & parameters, 363
List of Figuresfield access via pointers, 364
List of Tablfixeds keyword, 365–366 stackalloc keyword, 365
swap function, unsafe and safe, 363–364 unsafe keyword, 361–363
volatile keyword, 366
constructors
calls, forwarding using this,183–184 default,180
static,198–199
consumers of XML Web services, 1060–1061
contained controls, enumerating, 986–988
ContainerControl class, 637
containing and contained classes, 208
containment/delegation model
ArrayList type and, 318
C# and the .NET Platform, Second Edition programming for, 207–211
|
by Andrew Troelsen |
ISBN:1590590554 |
Contains() method, 677–678,726 |
|
|
contexts |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
AppDomain, processC# languageand threadand thenrelationshipquickly movesto, 474to key–475technical and
architectural issues for .NET developers. attributes,469–470
boundaries, defined, 468
context 0, 469
Table of Contents
context-agile and context-bound types, 469–470
C# and the .NET Platform, Second Edition
context-bound objects, creating, 470–471
Introduction
Context property, 1073
Part ContextMenuOne - Introd cingclass,C#649and–651the .NET Platform
Chapterproject1 -example,The Philosophy471–473of .NET
Chapter 2 - Building C# Applications
controls.See alsoWeb controls,ASP.NET;Windows Forms Controls
Part Two - The C# Programming Language
adding to Forms, 744–747
Chapter 3 - C# Language Fundamentals
AdRotator,996–997
Chapter 4 - Object-Oriented Programming with C# assigning ToolTips to, 769–770
Chapter 5 - Exceptions and Object Lifetime
calendar,995–996
ChapterCheckedListBox,6 - Interfaces758and–760Collections
ChapterControl7 -classC llback Interfaces, Delegates, and Events
Chapter core8 - propertiesAdvanced C#of, Type623 Construction Techniques
Part Threxample,- Programming634–635with .NET Assemblies
Chapter Form9 - Undstyles,rstandisetting,.NET624–Asse626mblies
members of, 624
Chapter 10 - Processes, AppDomains, Contexts, and Threads
painting basics, 635–636
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
properties and methods, 633–634,777
Part Four - Leveraging the .NET Libraries
Control events, 627–631
Chapter 12 - Object Serialization and the .NET Remoting Layer
control class example, 627–628
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Mouse events, responding to, 628–631
Chapter 14 - A Better Painting Framework (GDI+)
MouseEventArgs type properties, 629
Chapter 15 - Programming with Windows Forms Controls control flow constructs, C#, 137–139
Chapter 16 - The System.IO Namespace
Control$ControlCollection type, 745–747
Chapter 17 - Data Access with ADO.NET
Controls property, 986
Part Five - Web Applications and XML Web Services
data-centric (WebControls), 991,1004–1005
Chapter 18 - ASP.NET Web Pages and Web Controls
defined,789
Chapter 19 - ASP.NET Web Applications
DomainUpDown and NumericUpDown, 774–776
Chapter 20 - XML Web Services
Panel,773
Index
toolbox, HTML, 940
List ofTrackBar,Figures 770–772
List ofUp/Down,Tables 774–776
Windows Forms Controls. SeeWindows Forms Controls
conversions
among related class types, 387 conversion operators, 389–390 conversion routines
creating custom, 387–390 defining implicit, 390–391
internal representation of custom, 391–392 Convert type, 293
numerical,386–387
cookies,1047–1050
cookie data, reading incoming, 1049–1050 creating,1047–1049
coordinate systems, 687–692
default unit of measure, 688–689
C# and the .NET Platform, Second Edition |
|
point of origin, 690–692 |
ISBN:1590590554 |
by Andrew Troelsen |
|
unit of measure, default, 689–690 |
|
Apress © 2003 (1200 pages) |
|
CoorSystem application, 691–692 |
|
This comprehensive text starts with a brief overview of the cordbg.exe (commandC# languageline debugger),and then quickly55–57 moves to key technical and
architectural issues for .NET developers.
CreateText() method, 818,824
cross-language inheritance, 411–415
Table of Contents
csc.exe (C# compiler)
C# and the .NET Platform, Second Edition building applications with, 43–50
Introducticompilingn multiple source files, 49–50
Part Oneconfiguring,- Introducing44–C#45and the .NET Platform
Chapter output1 - Theoptions,Philosophy46 of .NET
Chapter referencing2 - BuildingexternalC# Applicationsassemblies, 48–50
Part options,Two - The54C#–55Programming Language
Chaptresponser 3 - C#files,Language50–52 Fundamentals
Chapter 4 - Object-Oriented Programming with C#
CSharpCalculator
Chapterapplications,5 - Exceptions15 and Object Lifetime
Chapterassembly,6 - Interfaces17–18 and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
CssStyle property, 997
Chapter 8 - Advanced C# Type Construction Techniques
CTS (Common Type System)
Part Three - Programming with .NET Assemblies
class types, CTS, 19
Chapter 9 - Understanding .NET Assemblies defined,7
Chapter 10 - Processes, AppDomains, Contexts, and Threads delegate types, 21
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming enumeration types, 21
Part Four - Leveraging the .NET Libraries
interface types, 21
Chapter 12 - Object Serialization and the .NET Remoting Layer intrinsic CTS data types, 22–23
Chapter 13 - Building a Better Window (Introducing Windows Forms) structure types, 20
Chapter 14 - A Better Painting Framework (GDI+)
type members, 22
Chapter 15 - Programming with Windows Forms Controls current objects, 183
Chapter 16 - The System.IO Namespace
CurrentThread(),342
Chapter 17 - Data Access with ADO.NET
PartcustomFive application- Web Applications-level exceptions,and XML Web243Servi–247ces
Chapter 18 - ASP.NET Web Pages and Web Controls
custom attributes
Chapterbuilding,19 - 523ASP–.NET524Web Applications
Chaptreflectionr 20 - XMLandWeblateServicesbinding example, 528–534
Index
custom class methods, defining, 140–143
List of Figures
accessibility keywords, 141
List of Tables
method access modifiers, 141–143
custom collections, building, 315–318
custom conversion routines creating,387–390
internal representation of, 391–392
custom dialog boxes, building, 781–787 application example, 782–785 DialogResult property, 785 grabbing data from, 785–787
custom enumerations, 164
custom exceptions and VS .NET, 255–256
custom indexer, building, 370–372
custom properties and sort types, 306
custom serialization example, 552–554
custom snap-in consumer, building, 529–530
C# and the .NET Platform, Second Edition
custom structures,by(un)boxing,A drew Troelsen170–171 |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
custom ToolBox bitmap, 802–803
custom types
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
consuming,1099–1100
architectural issues for .NET developers. conversions,386–387
exposing,1098–1099 Tablefromof ContentsWeb methods, exposing, 1096–1097
C# and the .NET Platform, Second Edition custom UserControl, building, 790–791
Introduction
custom validation, 1010–1012
Part One - Introducing C# and the .NET Platform
custom version policies, 440
Chapter 1 - The Philosophy of .NET
Chaptercustom2view- Buildingstate data,C# Applications1029
Part Two - The C# Programming Language
custom Web settings with <appSettings>, 1057
Chapter 3 - C# Language Fundamentals
custom Windows Forms Controls, building, 789–790
Chapter 4 - Object-Oriented Programming with C#
<customErrors>,1053–1054
Chapter 5 - Exceptions and Object Lifetime Chaptercustomizing6 - Interfacesserializationdprocess,Coll ctions549–554
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
||
|
|
|||
|
by Andrew Troelsen |
ISBN:1590590554 |
||
D |
Apress © 2003 (1200 pages) |
|
||
This comprehensive text starts with a brief overview of the |
||||
|
C# language and then quickly moves to key technical and |
|||
DashStyle enumeration, 710 |
|
|||
|
architectural issues for .NET developers. |
|
||
data access with ADO.NET. SeeADO.NET, data access with |
|
|||
Data Adapters |
|
|
|
|
Table of Contents |
|
|
|
|
building at design time, 922–926 |
|
|||
C# and the .NET Platform, Second Edition |
|
|||
Data Adapter Configuration Wizard, 922–926 |
|
|||
Introduction |
|
|
|
|
and design time connections, 926–927 |
|
|||
Part One - Introd |
cing C# and the .NET Platform |
|
||
using configured, 926 |
|
Chapter 1 - The Philosophy of .NET
data binding and data-centric controls, 1004–1005
Chapter 2 - Building C# Applications
data caching (example), 1038–1040
Part Two - The C# Programming Language
Chdatapter-centric3 - C#controlsLanguage(WebControls),Fundamentals991
Chapter 4 - Object-Oriented Programming with C#
Data Providers
ChapterADO5.NET,- Exceptions845–850and Object Lifetime
Chapter IDataAdapter6 - Interfacesinterface,and Collections848
Chapter IDataParameter7 - C llback Interfaces,interface,Delegates,846–847and Events
Chapter IDataReader8 - Advancedinterface,C# Type848Construc–850tion Techniques
Part ThreeIDataRecord- Programminginterface,with .848NET–Assemblies850
IDbCommand interface, 846–847
Chapter 9 - Understanding .NET Assemblies
IDbConnection and IDbTransaction interfaces, 846
Chapter 10 - Processes, AppDomains, Contexts, and Threads
IDbDataAdapter interface, 848
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
IDbDataParameter interface, 846–847
Part Four - Leveraging the .NET Libraries
selecting,887
Chapter 12 - Object Serialization and the .NET Remoting Layer
SQL,906–912
Chapter 13 - Building a Better Window (Introducing Windows Forms)
SqlDataAdapter, inserting records with, 907–910
Chapter 14 - A Better Painting Framework (GDI+)
SqlDataAdapter, updating records with, 910–912
Chapter 15 - Programming with Windows Forms Controls
System.Data.SQLTypes namespace, 907
Chapter 16 - The System.IO Namespace
data types, intrinsic CTS, 22–23
Chapter 17 - Data Access with ADO.NET
PartdatabasesFive - Web Applications and XML Web Services
Chapterbuilding18 - simpleASP.NETtest,Web886Pages and Web Controls
editors, integrated, 74
Chapter 19 - ASP.NET Web Applications
manipulation tools, 73–74
Chapter 20 - XML Web Services
schema information, 891–892
Index
ListDataColumnof Fig res type (ADO.NET), 852–858 List ofaddingTablesto DataTable, 855
auto-incrementing fields, 856–857 building a DataColumn, 854–855 configuring as primary key constraint, 855 DataColumnCollection type, 858 properties of, 853–854
XML data representation, configuring, 857–858
DataField attribute, 999
DataGrids, ADO.NET, 997–1005
column names, altering, 998–1000
data-centric controls and data binding, 1004–1005 in-place editing, 1001–1004
paging,1000–1001
DataRelation type, 879–883 properties of, 880
related tables navigation, 880–883
C# and the .NET Platform, Second Edition
DataRelationCollection,874 |
ISBN:1590590554 |
by Andrew Troelsen |
|
DataRow type, 858Apress–861© 2003 (1200 pages) |
|
DataRow.GetChildRows()This comprehensivemethod, 882text starts with a brief overview of the
C# language and then quickly moves to key technical and
DataRow.RowState property, 859–861
architectural issues for .NET developers.
DataSets
DataSet type, 874–879
Table of Contents
in-memory DataSet, building, 876–879
C# and the .NET Platform, Second Edition
members of, 875–876
Introductionat design time, 927–931
Part Onetyped- IntroducingDataSets,C#927and–931the .NET Platform
Chapter untyped1 - TheDataSets,Philosophydefined,of .NET 927
Chapterfilling2 multitabled,- Building C#916Applications–919
Part fillingTwo -withThe C#OleDbDataAdapterProgramming Languagetype, 903–904
Chaptreadingr 3 -andC# Languagewriting XMLFundamentals-based, 883–885
Chapter 4 - Object-Oriented Programming with C#
DataTables
Chapteradding5 -DataColumnExceptions andtypeObjectto, 855Lifetime
Chapterbuilding,6 - 863Interface–871s and Collections
Chapter filters7 - Callbackand sortInterfaces,orders, 867Delegates,–869 and Events
Chapter rows,8 - Advanceddeleting, 866C# Type–867Construction Techniques
Part Threerows,- Progrupdating,mming869with–871.NET Assemblies
DataTable type, 836,844,861–863
Chapter 9 - Understanding .NET Assemblies
ChapterDataView10 type,- Processes,871–873AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
DateTime type, 766–767
Part Four - Leveraging the .NET Libraries
DCOM (Distributed Component Object Model) clients, 1059–1060
Chapter 12 - Object Serialization and the .NET Remoting Layer
DDL (Data Definition Language) commands, 898
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterDeactivate14 -event,A Better641Painting–642 Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
debugger, command line (cordbg.exe). Seecordbg.exe (command line debugger)
Chapter 16 - The System.IO Namespace
debugging
Chapter 17 - Data Access with ADO.NET vs. running, 71
Part Five - Web Applications and XML Web Services
system exceptions with VS .NET, 253–256
Chapter 18 - ASP.NET Web Pages and Web Controls and tracing ASP.NET pages, 1020
Chapter 19 - ASP.NET Web Applications
default assignments and variable scope, 102–104
Chapter 20 - XML Web Services Indexdefault behaviors, overriding, 118–119
List of Figures
default constructors, defined, 98–99
List of Tables
default contexts, 469 default input Button, 767
default lease characteristics, altering, 593–594 default leasing behavior, 590–592
default merge system (MDI applications), 666 default namespace of VS .NET, 175–176 default .NET Remoting architecture, 559 default parameter passing behavior, 148 default properties and events, defining, 802 default public interface of a type, 184–186 default remoting layers, extending, 560 default response file (csc.rsp), 51–52
default unit of measure, 688–689
C# and the .NET Platform, Second Edition
default.htm form data, 946 |
ISBN:1590590554 |
||
by Andrew Troelsen |
|||
DefaultWsdlHelpGeneratorApress © 2003.aspx,(12001066pages) |
|
||
|
|
|
|
delayed signing, This434–comprehensive435 text starts with a brief overview of the
C# language and then quickly moves to key technical and
delegate types, .NET
architectural issues for .NET developers. asynchronous delegates, 341–347
callbacks for, 344–347
Table ofinvokingContentsmethods asynchronously, 343–344
building (example), 333–341
C# and the .NET Platform, Second Edition
CarDelegate,334–337
Introduction
delegates as nested types, 334
Part One - Introducing C# and the .NET Platform
delegation code, analyzing, 337–338
Chapter 1 - The Philosophy of .NET
instance methods as callbacks, 339–341
Chapter 2 - Building C# Applications
multicasting with Car.CarDelegate, 338–339
Part Two - The C# Programming Language
example,329–332
Chapter 3 - C# Language Fundamentals
multicasting with, 332
Chapter 4 - Object-Oriented Programming with C#
System.MulticastDelegate,328–329
Chapter 5 - Exceptions and Object Lifetime understanding,325–328
Chapter 6 - Interfaces and Collections
delegates
Chapter 7 - Callback Interfaces, Delegates, and Events
CTS types, 21
Chapter 8 - Advanced C# Type Construction Techniques
defined,325
Part Three - Programming with .NET Assemblies
defining in C#, 326–328
Chapter 9 - Understanding .NET Assemblies delegate keyword
Chapter 10 - Processes, AppDomains, Contexts, and Threads to create delegates in C#, 326
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming for declaring a .NET delegate, 330
Part Four - Leveraging the .NET Libraries
defined,321
Chapter 12 - Object Serialization and the .NET Remoting Layer
EventHandler,619
Chapter 13 - Building a Better Window (Introducing Windows Forms) multithreaded programming via, 476
Chapter 14 - A Better Painting Framework (GDI+) delegation
Chapter 15 - Programming with Windows Forms Controls code, analyzing, 337–338
Chapter 16 - The System.IO Namespace defined,209
Chapter 17 - Data Access with ADO.NET
Delete() method
Part Five - Web Applications and XML Web Services
DataTables,867
Chapter 18 - ASP.NET Web Pages and Web Controls
from FileSystem Info type, 808
Chapter 19 - ASP.NET Web Applications
DELETE SQL statements, 848
Chapter 20 - XML Web Services
Indexdeleting records with OleDbCommand, 897–898
List of Figures
deploying
List of Tables
.NET applications, 397
.NET Remoting projects, 566–567
descending values (font metrics), 697
Description property, documenting Web methods with, 1073–1074
description service, XML Web, 1063
deserialization process, 550
Deserialize() method, 545–546
design time
connections and Data Adapters, 926–927 functionality,798
GUI, building, 792
destruction methods, building, 264–266 IDisposable interface, 264–265 using keyword, 265–266
dialog boxes, building custom, 781–787
C# and the .NET Platform, Second Edition application example, 782–785
by Andrew Troelsen ISBN:1590590554
DialogResult property, 785
Apress © 2003 (1200 pages)
grabbing data from, 785–787
This comprehensive text starts with a brief overview of the
dictionary, defined, 309
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Directory class, static members of, 812–813
DirectoryInfo and FileInfo types, 806–812
DirectoryInfo type
Table of Contents
creating subdirectories with, 811–812
C# and the .NET Platform, Second Edition
enumerating files with, 810–811
Introduction
working with, 808–809
Part One - Introducing C# and the .NET Platform
DirectoryInfo.CreateSubdirectory() method, 811–812
Chapter 1 - The Philosophy of .NET
FileAttributes enumeration, 809–810
Chapter 2 - Building C# Applications
FileSystemInfo base class, 807–808
Part Two - The C# Programming Language
dirty windows (Paint), 681
Chapter 3 - C# Language Fundamentals
ChapterDISCO4(Discovery- Obj ct-ofOrientedWeb Services),Programming1062with–1063C#
Chapter 5 - Exceptions and Object Lifetime
disconnected layer, ADO.NET, 844,901–905
Chapter 6 - Interfaces and Collections discovery service, XML Web, 1062–1063
Chapter 7 - Callback Interfaces, Delegates, and Events
dispatcher, defined, 559
Chapter 8 - Advanced C# Type Construction Techniques
PartdisplayThreenames,- Programmingdefined, 512with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies disposable and finalizable types, building, 268–269
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Dispose() method
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
creation of, 264–265
Part Four - Leveraging the .NET Libraries
GDI+ and, 680
Chapter 12 - Object Serialization and the .NET Remoting Layer role in building Windows Forms, 614–615
Chapter 13 - Building a Better Window (Introducing Windows Forms) distributed applications, building, 568–571
Chapter 14 - A Better Painting Framework (GDI+) general assembly, 568
Chapter 15 - Programming with Windows Forms Controls server assembly, 569–570
Chapter 16 - The System.IO Namespace
SimpleRemoteObjectClient.exe assembly, 570–571
Chapter 17 - Data Access with ADO.NET
Distributed .NET Programming in C# (Apress, 2002), 567,606
Part Five - Web Applications and XML Web Services
DLL hell, 396
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapterdo/while19and- ASPwhile.NETloopingWeb Applicationsconstructs, 136–137
Chapter 20 - XML Web Services
docking behavior, configuring, 780–781
Index
DockStyle values, 780
List of Figures
documentation support, VS .NET, 81
List of Tables
DOM (Document Object Model), 944
Domain Name System (DNS), 935–936
DomainUnload event, 468
DomainUpDown control
and NumericUpDown Control, 774–776 properties,775
Dotnetfx.exe package (Microsoft), 40
dragging mode (GDI+), 723–725
DraggingImages application, 727
Drawing utility types, 675–680 disposal of, 680
Point(F) type, 675–676
Rectangle(F) type, 677–678
Region class, 678–679
C# and the .NET Platform, Second Edition
Size(F) types, 678
by Andrew Troelsen |
ISBN:1590590554 |
DrawString() method, 675 |
|
Apress © 2003 (1200 pages) |
|
DrawXXXX() methods, 707
This comprehensive text starts with a brief overview of the
dumping C# language and then quickly moves to key technical and
architectural issues for .NET developers.
CIL instructions to file, 36–37 namespace information to file, 35–36
TableDynamicof ContentsHelp Window, 74
C# and the .NET Platform, Second Edition
dynamic invocation, 517–520
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
E |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
early binding, 517 |
|
architectural issues for .NET developers.
editing tools, XML-related, 72–73
EJB (Enterprise Java Beans), 1059–1060
Table of Contents
embedded resources, 739–740
C# and the .NET Platform, Second Edition
EmpType enumeration, 164
Introduction
PartEnableRaisingEventsOne - Introduci C#property,and the831.NET Platform
Chapter 1 - The Philosophy of .NET
EnableSession property, 1075–1077
Chapter 2 - Building C# Applications
EnableViewState property, 1029
Part Two - The C# Programming Language
encapsulation services, 191–199
Chapter 3 - C# Language Fundamentals
class properties, 193–195
Chapter 4 - Object-Oriented Programming with C#
enforcing with accessors and mutators, 192–193
Chapter 5 - Exceptions and Object Lifetime
fundamentals of, 187
Chapter 6 - Interfaces and Collections
internal representation of C# properties, 196–197
Chapter 7 - Callback Interfaces, Delegates, and Events
read-only and write-only properties, 197–198
Chapter 8 - Advanced C# Type Construction Techniques static properties, 198–199
Part Three - Programming with .NET Assemblies
EndEdit() method (DataTables), 870
Chapter 9 - Understanding .NET Assemblies
ChapterEndInvoke()10 - Processes,method, 343AppDomains,–346 Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
EndRead() and EndWrite() methods, 833
Part Four - Leveraging the .NET Libraries
#endregion and #region tags, 83
Chapter 12 - Object Serialization and the .NET Remoting Layer
EngineState enumeration, viewing for, 500–501
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterEnterprise14 -ManagerA Bett Painting(SQL Server),Framework886 (GDI+)
Chapter 15 - Programming with Windows Forms Controls enumerating
Chapter 16 - The System.IO Namespace class members, 513–514
Chapter 17 - Data Access with ADO.NET contained controls, 986–988
Part methodFive - Webparameters,Applications514and–515XML Web Services
Chapterrunning18 -processes,ASP.NET Web456Pages–457and Web Controls
Chaptertypes19in- referencedASP.NET Webassemblies,Applications513
Chapter 20 - XML Web Services
enumeration types, CTS, 21
Index
enumerations, custom, 164
enumerators, building custom, 293–297
List of Tables
Enum.Format() method, 167 equality operators, 160,378–379 Equals(),119–120,378
error events, 979–981
error output, customizing with <customErrors>, 1053–1054 ErrorBlinkStyle properties, 778
ErrorProvider type, 776–778
errors, bugs and exceptions defined, 231–232 escape characters and verbatim strings,161–162
Essential Guide to Managed Extensions for C++ (Apress, 2002), 413–414
events
event keyword, 347
event sinks, multiple, 349,352
C# and the .NET Platform, Second Edition
EventArgs parameter, 619
by Andrew Troelsen |
ISBN:1590590554 |
EventHandler delegate, 619 |
|
Apress © 2003 (1200 pages) |
|
exception event handler (Global.asax), 1031–1032 |
|
This comprehensive text starts with a brief overview of the understanding and using, 347–354
C# language and then quickly moves to key technical and events under the hood, 348–350
architectural issues for .NET developers. incoming events, 351–353
objects as event sinks, 353–354
Tableexceptions,of Contents231–256
C# and.NETtheexception.NET Platform,handling,Second232Edition–233
application-level
Introduction
building custom, 243–247
Part One - Introducing C# and the .NET Platform
and system-level exceptions, 252
Chapter 1 - The Philosophy of .NET
catching exceptions, 236–240
Chapter 2 - Building C# Applications
HelpLink property, 239–240
Part Two - The C# Programming Language
StackTrace property, 239
Chapter 3 - C# Language Fundamentals
TargetSite property, 238–239
Chapter 4 - Object-Oriented Programming with C#
CLR system-level exceptions, 240–242
Chapter 5 - Exceptions and Object Lifetime
debugging system exceptions with VS .NET, 253–256
Chapter 6 - Interfaces and Collections
errors, bugs and exceptions defined, 231–232
Chapter 7 - Callback Interfaces, Delegates, and Events exception event handler (Global.asax), 1031–1032
Chapter 8 - Advanced C# Type Construction Techniques finally blocks, 250
Part Three - Programming with .NET Assemblies
generic exceptions, throwing, 235–236
Chapter 9 - Understanding .NET Assemblies handling multiple, 247–250
Chapter 10 - Processes, AppDomains, Contexts, and Threads generic catch statements, 249
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming rethrowing exceptions, 249–250
Part lastFourchance- Leveragingexceptions,the .NET251Libraries
ChapterSystem12 -.ExceptionObj ct Serializationbase class,and234the–235.NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms) explicit and implicit keywords, 387–389
Chapter 14 - A Better Painting Framework (GDI+)
explicit casting, 223,277–278
Chapter 15 - Programming with Windows Forms Controls
explicit conversion operators, 389–390
Chapter 16 - The System.IO Namespace
Chaexplicitter 17interface- Data implementation,Access with ADO.281NET–284
Part Five - Web Applications and XML Web Services
explicit load request (assemblies), 429
Chapter 18 - ASP.NET Web Pages and Web Controls
ExtendedProperties property, 874–875
Chapter 19 - ASP.NET Web Applications
extendible applications, 529,532–534
Chapter 20 - XML Web Services
Indexextending default remoting layers, 560
List of Figures
Extends metadata tokens, 501
List of Tables external assemblies
referencing,32,48–49 referencing multiple (csc.exe), 50 referencing via VS .NET, 67–68
external resources, bundling, 732–733
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
F |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
feature-rich controls (WebForms), 995–997 |
|
architectural issues for .NET developers.
fields defined,191
Tablefieldof Contaccessntsvia pointers, 364
C# andFieldthe#n.NETtokens,Platform,501 Second Edition
FieldCount property, 895
Introduction
read-only,199–201
Part One - Introducing C# and the .NET Platform
ChapterFile Save1 dialog- The Philosophybox, 838–839of .NET
Chapter 2 - Building C# Applications
FileAccess enumeration values, 816
Part Two - The C# Programming Language
FileAttributes enumeration, 809–810
Chapter 3 - C# Language Fundamentals
FileInfo and DirectoryInfo types, 806–810
Chapter 4 - Object-Oriented Programming with C#
DirectoryInfo type, 808–809
Chapter 5 - Exceptions and Object Lifetime
FileAttributes enumeration, 809–810
Chapter 6 - Interfaces and Collections
FileSystemInfo base class, 807–808
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterFileInfo8class,- Advanced814–818C# Type Construction Techniques
Part FileInfoThree -.ProgrammingCreate() method,with815.NET Assemblies
Open() method, 815–817
Chapter 9 - Understanding .NET Assemblies
OpenRead() and OpenWrite() members, 817
Chapter 10 - Processes, AppDomains, Contexts, and Threads
OpenText(), CreateText(), AppendText() members, 817–818
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartFileModeFour - Leveragingenumerationthevalues,.NET Libraries816
Chapter 12 - Object Serialization and the .NET Remoting Layer
File.OpenText() method, 826
Chapter 13 - Building a Better Window (Introducing Windows Forms)
FileShare enumeration values, 817
Chapter 14 - A Better Painting Framework (GDI+)
FileStreams,820
Chapter 15 - Programming with Windows Forms Controls
ChapterFileStream16 -.Write()The Systemmethod,.IO Namespace822
Chapter 17 - Data Access with ADO.NET
FileSystemEventHandler delegate, 831
Part Five - Web Applications and XML Web Services
FileSystemInfo base class, 807–808
Chapter 18 - ASP.NET Web Pages and Web Controls
FileSystemWatcher class, 831–833
Chapter 19 - ASP.NET Web Applications
ChapterFill() method,20 - XML848Web Services
Index
filling DataSets with OleDbDataAdapter type, 903–904 FillPath() method, 729
FillXXXX() methods, 707,713
filters and sort orders (DataTables), 867–869 finalizable and disposable types, building, 268–269 finalization reachable tables (freachable), 263 Finalize() method, 260–262
finalizing types, 260–263 finally blocks, 250
firing events, 348
fixed keyword, pinning types via, 365–366
fonts
application, building, 698–703
installed fonts, enumerating, 701–703 System.Drawing.Text,701–703
font dialog box, 703
C# and the .NET Platform, Second Edition
FontDialog class, 703–704
by Andrew Troelsen |
ISBN:1590590554 |
FontFamily type members, 696 |
|
Apress © 2003 (1200 pages) |
|
FontFamily.Name property, 701 |
|
This comprehensive text starts with a brief overview of the
FontStyle enumeration, 695
C# language and then quickly moves to key technical and manipulating,695–698
architectural issues for .NET developers. font families, 696–697
font metrics, 697–698
Tablefor loop,of Contents135
C# and the .NET Platform, Second Edition
foreach/in loop, 135–136
Introduction
format characters, XML, 80
Part One - Introducing C# and the .NET Platform
formatters
Chapter 1 - The Philosophy of .NET
.NET,559
Chapter 2 - Building C# Applications
serialization,544–545
Part Two - The C# Programming Language
Chapterformatting3 -flags,C# Languagestring, 107Fundamentals–109
Chapter 4 - Object-Oriented Programming with C# formatting textual output, 106–107
Chapter 5 - Exceptions and Object Lifetime
Forms
Chapter 6 - Interfaces and Collections
adding controls with VS .NET, 747–749
Chapter 7 - Callback Interfaces, Delegates, and Events
Form class, 637–640
Chapter 8 - Advanced C# Type Construction Techniques
example,639–640
Part Three - Programming with .NET Assemblies
key methods of, 638–639
Chapter 9 - Understanding .NET Assemblies
properties of, 638
Chapter select10 - Processes,events of,AppDomains,639 Contexts, and Threads
ChapterForm11data- Type Reflection, Late Binding, and Attribute-Based Programming
Part Fouraccess- Leveragingto incoming,the .NET975Libraries
Chapter submitting,12 - Object947Serialization and the .NET Remoting Layer
ChapterForm13inheritance,- Bu lding 787Better–789Window (Introducing Windows Forms)
Form level events, handling with VS .NET, 643–644
Chapter 14 - A Better Painting Framework (GDI+)
Form property (HttpRequest), 975
Chapter 15 - Programming with Windows Forms Controls
FormBorderStyle properties, 779
Chapter 16 - The System.IO Namespace
HTML Form development, 940–943
Chapter 17 - Data Access with ADO.NET
Web Forms, 607–608
Part Five - Web Applications and XML Web Services
Windows.SeeWindows Forms;Windows Forms Controls
Chapter 18 - ASP.NET Web Pages and Web Controls
freachable (finalization reachable table), 263
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
G |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
C# language and then quickly moves to key technical and
GAC (Global Assembly Cache)
architectural issues for .NET developers. internal composition of, 440–442
loading items from, 516–517
shared assemblies and, 430–431,436
Table of Contents
C#Garageand theclass.NETdefinition,Platform,335Second–336Edition
Introduction
garbage collection (GC), 257–272
Part basicsOne - Introducingof, 259–260C# and the .NET Platform
ChapterCIL1of new- Thekeyword,Phil sophy257of–259.NET
Chaptdestructionr 2 - Buildingmethod,C# Applicationsbuilding, 264–266
Part TwoIDisposable- The C# Programminginterface, 264Language–265
Chapter using3 - C#keyword,Languagereusing,Fundamentals265–266
Chapterfinalization4 - Objectprocess,-Oriented263Programming with C#
finalizing types, 260–263
Chapter 5 - Exceptions and Object Lifetime
GC.Collect(),270
Chapter 6 - Interfaces and Collections
GC.GetGeneration(),270
Chapter 7 - Callback Interfaces, Delegates, and Events
object lifetime, 257
Chapter 8 - Advanced C# Type Construction Techniques
optimizations of, 267
Part Three - Programming with .NET Assemblies
System.GC types, 267–272
Chapter 9 - Understanding .NET Assemblies
finalizable and disposable types, building, 268–269
Chapter 10 - Processes, AppDomains, Contexts, and Threads forcing garbage collections, 270
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming generations, programmatically interacting with, 270–272
Part Four - Leveraging the .NET Libraries
GDI+ (Graphics Device Interface), 671–742
Chapter 12 - Object Serialization and the .NET Remoting Layer
.NET resource format, 732–733
Chapter 13 - Building a Better Window (Introducing Windows Forms)
active colors, establishing, 692–694
Chapter 14 - A Better Painting Framework (GDI+)
color type members, 693
Chapter 15 - Programming with Windows Forms Controls
ColorDialog class, 693–694
Chapter 16 - The System.IO Namespace coordinate systems, 687–692
Chapter 17 - Data Access with ADO.NET point of origin, 690–692
Part Five - Web Applications and XML Web Services
unit of measure, 688–690
Chapter 18 - ASP.NET Web Pages and Web Controls
dragging,723–725
Chapter 19 - ASP.NET Web Applications
font application, building, 698–703
Chapter 20 - XML Web Services
installed fonts, enumerating, 701–703
Index System.Drawing.Text,701–703
List ofFontDialogFigures class, 703–704
List offonts,Tablesmanipulating, 695–698 families,696–697 metrics,697–698
GDI+ Programming in C# and VB .NET (Apress, 2002), 742 GdiPlusApp,1016
Graphics class, 685–686 hit testing, 723,727–731 images, rendering, 720–723
namespaces overview, 671–772 paint sessions, 680–684
client area, invalidating, 682
obtaining graphics type from Windows Forms controls, 683–684 obtaining graphics type outside paint handler, 682–683
PictureBox control, 723–727
resource configuration with VS .NET, 739–742 ResourceManagers,737–739
ResourceWriters,737
C# and the .NET Platform, Second Edition
System.Drawing namespace, 673–675
by Andrew Troelsen |
ISBN:1590590554 |
System.Drawing utility types, 675–679 |
|
Apress © 2003 (1200 pages) |
|
disposal of, 680 |
|
This comprehensive text starts with a brief overview of the
Point(F) type, 675–676
C# language and then quickly moves to key technical and
Rectangle(F) type, 677–678
architectural issues for .NET developers.
Region class, 678–679
Size(F) types, 678
System.Drawing.Drawing2D namespace overview, 705–720
Table of Contents
gradient brushes, 719–720
C# and the .NET Platform, Second Edition
hatch style brushes, 715–717
Introduction
pen caps, 711–713
Part One - Introducing C# and the .NET Platform
pen objects, 707–711
Chapter 1 - The Philosophy of .NET rendering quality, 706–707
Chapter 2 - Building C# Applications solid brushes, 713–715
Part Two - The C# Programming Language
textured brushes, 717–718
Chapter 3 - C# Language Fundamentals
System.Resources namespace, 733–737
Chapter 4 - Object-Oriented Programming with C#
*.resources file, binding into .NET assembly, 736–737
Chapter 5 - Exceptions and Object Lifetime
*.resources file, building, 735–736
Chapter 6 - Intfile,rfaces and Collections
*.resx creating and reading, 733–735
Chapteron Web7 - server,Callback1016Interfaces,–1019 Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques general assembly, building, 568
Part Three - Programming with .NET Assemblies
generations, object
Chapter 9 - Understanding .NET Assemblies
defined,267
Chapter 10 - Processes, AppDomains, Contexts, and Threads programmatically interacting with, 270–272
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
generic catch statements, 249
Part Four - Leveraging the .NET Libraries
Chaptergeneric12class- Objecttypes,Serialization789 and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms) generic exceptions, throwing, 235–236
Chapter 14 - A Better Painting Framework (GDI+)
GET and POST methods, 947,949–950
Chapter 15 - Programming with Windows Forms Controls
get_ and set_ methods, 196–197
Chapter 16 - The System.IO Namespace
ChapterGET messages,17 - Data HTTP,Access with1087ADO.NET
Part Five - Web Applications and XML Web Services
GetBoolean() method, 895
Chapter 18 - ASP.NET Web Pages and Web Controls
GetCommandLineArgs(),96
Chapter 19 - ASP.NET Web Applications
GetDateTime() method, 969
Chapter 20 - XML Web Services
IndGetFiles()x method, 810
List of Figures
GetHashCode(), overriding, 120–122
List of Tables
GetInterfaceMap() method, 509
GetObjectData() method, 550
GetOleDbSchemaTable() method, 891–892
GetParentRows() method, 882
GetStringBuilder() method, 826
GetStyle() method, 624
GetTheData() method, 957
GetType() method, 505–506
GetTypeCode() method, 292–293
Global.asax file, 1030–1032
exception event handler, 1031–1032 HttpApplication base class, 1032
gradient brushes, 719–720
graphics
C# and the .NET Platform, Second Edition
Graphics class
by Andrew Troelsen |
ISBN:1590590554 |
drawing members of, 707–708 |
|
Apress © 2003 (1200 pages) |
|
fundamentals of, 685–686 |
|
graphics typeThis comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
obtaining from Windows Forms controls, 683–684 architectural issues for .NET developers.
obtaining outside paint handler, 682–683
Graphics.DrawString() method, 695
TableGraphicsof Contents.FromHwnd() method, 682–683
Graphics.PageUnit property, 690
C# and the .NET Platform, Second Edition
GraphicsPath class, 729–730
Introduction
GraphicsUnit enumeration, 689
Part One - Introducing C# and the .NET Platform
ChapterGroupBoxes1 - TheandPhilosophyRadioButtons,of .NET756–760
Chapter 2 - Building C# Applications
GUI (Graphical User Interface)
Part Two - The C# Programming Language
of *.aspx pages, 963
Chapter 3 - C# Language Fundamentals
namespaces,607–608
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
H |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
has-a and is-a relationships, 187–189,201–203,207–210 |
|
architectural issues for .NET developers.
hatch style brushes, 715–717
HatchStyle enumeration, 715–716
Table of Contents
HeaderText attribute, 999
C# and the .NET Platform, Second Edition
HelloWS WSDL document, viewing, 1082–1084
Introduction
ParthelpOnesystem,- Introducingintegrated,C# 74and–76the .NET Platform
Chapter 1 - The Philosophy of .NET
HelpLink property, 239–240
Chapter 2 - Building C# Applications
hierarchies
Part Two - The C# Programming Language
building interface, 285–288
Chapter 3 - C# Language Fundamentals
System.Collections interfaces, 307
Chapter 4 - Object-Oriented Programming with C#
hit testing, 723,727–731
Chapter 5 - Exceptions and Object Lifetime
Chostingap er 6remote- Interfacesobjects,and597Collections–598
Chapter 7 - Callback Interfaces, Delegates, and Events
HTML (Hypertext Markup Language)
Chapter 8 - Advanced C# Type Construction Techniques capturing widget events with VS .NET, 945
Part content,Three - Programmingemitting, 977with .NET Assemblies
Chaptercontrols,9 - Understanding1014–1016 .NET Assemblies
Chaptercontrols10 - toolbox,Pr cesses,940AppDomains, Contexts, and Threads
Chapterdocument11 - Typestructure,Reflection,939Late–940Binding, and Attribute-Based Programming
Part formFour -development,Leveraging the940.NET–943Libraries
ChapterGUI12types,- Object941 Serialization and the .NET Remoting Layer
HTML-based user interface, building, 941–943
Chapter 13 - Building a Better Window (Introducing Windows Forms)
tables, building, 994–995
Chapter 14 - A Better Painting Framework (GDI+)
ChapterHTTP (Hypertext15 - ProgrammingTransferwithProtocol)Windows Forms Controls
Chapterchannel,16 - Thedefined,System558.IO Namespace
Chapterfundamentals17 - Data Accessof, 935with–936ADO.NET
Part GETFive -andWebHTTPApplicationsPOST messages,and XML Web1087Services
HttpApplication base class, 1032
Chapter 18 - ASP.NET Web Pages and Web Controls
HttpApplication type, 1050
Chapter 19 - ASP.NET Web Applications
HttpApplicationState type, 1033–1034,1037–1038
Chapter 20 - XML Web Services
HttpContext type, 1073
Index
HttpRequest type members, 972
List of Figures
HttpRequest.Browser property, 944
List of Tables
HttpResponse type properties and methods, 976
HttpServerUtility type, 1073
HttpServerUtility.ClearError(),980–981
HttpServerUtility.GetLastError(),980
HttpSessionState members, 1045–1046
HttpSessionState type, 1033
requests, interacting with incoming, 971–975 form data access, 975
HttpRequest type members, 972 obtaining browser statistics, 973 server variables, access to, 974
responses, interacting with outgoing, 975–978 HTML content, emitting, 977
HttpResponse type properties and methods, 976 redirecting users, 977–978
hyperthreading,453
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
I |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
IAsyncResult interface, 1093 |
|
architectural issues for .NET developers.
IChannel interface, 558,572–573
ICloneable interface, 297–302
Table of Contents
ICollection interface, 307,308
C# and the .NET Platform, Second Edition
IComparable interface, 302–306
Introduction
PartIComparerOne - Introducinginterface, C#304and–307the .NET Platform
Chapter 1 - The Philosophy of .NET
IComponent interface, 622
Chapter 2 - Building C# Applications
IConvertible interface, 290–293
Part Two - The C# Programming Language
IConvertible.GetTypeCode(),292–293
Chapter 3 - C# Language Fundamentals
IConvertible.ToXXXX() members, 291–292
Chapter 4 - Object-Oriented Programming with C#
System.Convert type, 293
Chapter 5 - Exceptions and Object Lifetime
IDataAdapter interface, 848
Chapter 6 - Interfaces and Collections
ChapterIDataParameter7 - Callbackinterface,Interfaces,846–Delegates,847 and Events
Chapter 8 - Advanced C# Type Construction Techniques
IDataParameterCollection,847
Part Three - Programming with .NET Assemblies
IDataReader interface, 848–850
Chapter 9 - Understanding .NET Assemblies
IDataRecord interface, 848–850
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterIDbCommand11 - Typeinterface,Reflection,846Late–847Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
IDbConnection and IDbTransaction interfaces, 846
Chapter 12 - Object Serialization and the .NET Remoting Layer
IDbDataAdapter interface, 848
Chapter 13 - Building a Better Window (Introducing Windows Forms)
IDbDataParameter interface, 846–847
Chapter 14 - A Better Painting Framework (GDI+)
Chapteridentity15of -privateProgrammingassemblies,with 426Windows Forms Controls
Chapter 16 - The System.IO Namespace
IDEs (Integrated Development Environments), building .NET applications with, 89–90
Chapter 17 - Data Access with ADO.NET
IDictionary interface, 307–309
Part Five - Web Applications and XML Web Services
IDictionaryEnumerator interface, 309
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapterIDispatch19 reference- ASP.NET(COM),Web Applications517
Chapter 20 - XML Web Services
IDisposable interface, 264–265
Index
IDL (Interface Definition Language), 16–17,499–500,520–521
List of Figures
IDraw and IDraw3D, 284
List of Tables
IEnumerable and IEnumerator interfaces, 293–297,307,1005
if/else statements, 137–138
IFormatProvider,292
IFormatter and IRemotingFormatter interfaces, 544
IHashCodeProvider interface, 307,309
IIS (Internet Information Server)
basics,936–937
hosting remote objects with, 602–603 virtual directories, 938,1066
ildasm.exe
assembly metadata, viewing, 37–38 dumping CIL instructions to file, 36–37 dumping namespace info to file, 35–36
tree view icons, 33–35
C# and the .NET Platform, Second Edition
ILease interface, 591 |
ISBN:1590590554 |
||
by Andrew Troelsen |
|||
IList interface, 307Apress,309–©3102 03 (1200 pages) |
|
||
|
|
|
|
ImageIndex propertyThis (ToolBars),comprehensive665text–666starts with a brief overview of the
C# language and then quickly moves to key technical and images architectural issues for .NET developers.
creating,791
hit testing nonrectangular, 729–731 Tablerendering,of Contents720–723
C#IMessageand the .NET Platform, Second Edition
interface, 557
Introduction
IMessageFilter interface, 620
Part One - Introducing C# and the .NET Platform
Implement Interface Wizard, 289–290I
Chapter 1 - The Philosophy of .NET
Chaimplicitter 2conversion- Buildi groutines,C# Applications390–391
Part Two - The C# Programming Language
implicit load request (assemblies), 429
Chapter 3 - C# Language Fundamentals
<%Import%> directive, 955–956
Chapter 4 - Object-Oriented Programming with C#
Imports keyword (VB .NET), 410
Chapter 5 - Exceptions and Object Lifetime
Chaptin-memoryr 6 -DataSet,Interfacesbuilding,and Collections876–879
Chaplaceter 7 - Callback Interfaces, Delegates, and Events
inediting (DataGrids), 1001–1004
Chapter 8 - Advanced C# Type Construction Techniques incoming events, listening to, 351–353
Part Three - Programming with .NET Assemblies
indexers
Chapter 9 - Understanding .NET Assemblies
building custom, 370–373
Chapter 10 - Processes, AppDomains, Contexts, and Threads
C# indexer from VB .NET, 374–375
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Cars indexer variation, 372–373
Part Four - Leveraging the .NET Libraries
type indexers, 373–374
Chapter 12 - Object Serialization and the .NET Remoting Layer
informational text string, 403
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapterinheritance14 - A Better Painting Framework (GDI+)
Chapterclassical,15 - Programming188 with Windows Forms Controls
configuration,1057–1058
Chapter 16 - The System.IO Namespace
cross-language,411–415
Chapter 17 - Data Access with ADO.NET
Form,787–789
Part Five - Web Applications and XML Web Services
Inheritance Picker (Wizard), 788
Chapter 18 - ASP.NET Web Pages and Web Controls
Inherits attribute, 968
Chapter 19 - ASP.NET Web Applications
is-a and has-a relationships, 187–189
Chapter 20 - XML Web Services
preventing,205–207
Index
support, C#, 201–205
List of Figures
base class creation, 203–204
List of Tables
multiple base classes, 204
Init events, ASP.NET, 978–979
initialization syntax, variable, 104–105
InitializeComponent(),614–615
INSERT SQL statements, 848
inserting records
with OleDbCommand, 897–898 with SqlDataAdapter, 907–910
instance level CTS members, defined, 22
instance methods as callbacks, 339–341
integrated database editors, 74
integrated help system, 74–76
integrated object browser, 73
interface-based event protocol, 324
C# and the .NET Platform, Second Edition
Interface Definition Language (IDL). SeeIDL(Interface Definition Language)
by Andrew Troelsen ISBN:1590590554
interface keyword,Apress273,276© 2003–277(1200 pages)
This comprehensive text starts with a brief overview of the interfaces.See alsointerfaces and collections
C# language and then quickly moves to key technical and as parameters, 280–281,284–285
architectural issues for .NET developers. callback,321–325
cloneable objects, building, 297–302
comparable objects, building, 302–306
Table of Contents
custom properties and sort types, 306
C# and the .NET Platform, Second Edition
multiple sort orders, 304–305
Introduction
CTS types, 21
Part One - Introducing C# and the .NET Platform
custom collections, building, 315–318
Chapter 1 - The Philosophy of .NET
defining with C#, 273–277
Chapter 2 - Building C# Applications
abstract base classes vs. interfaces, 276–277
Part Two - The C# Programming Language
implementing with C#, 274–276
Chapter 3 - C# Language Fundamentals enumerators, building custom, 293–297
Chapter 4 - Object-Oriented Programming with C# explicit interface implementation, 281–284
Chapter 5 - Exceptions and Object Lifetime hierarchies, building, 285–288
Chapter 6 - Interfaces and Collections
HTML-based user, building, 941–943
Chapter 7 - Callback Interfaces, Delegates, and Events
IAsyncResult,1093
Chapter 8 - Advanced C# Type Construction Techniques
IChannel,558
Part IChannelThree - Programmingdefinition, 572with–573.NET Assemblies
ChapterIComponent,9 - Understanding622 .NET Assemblies
ChapterIConvertible10 - Processes,interface,AppDomains,290–293 Contexts, and Threads
Chapter IConvertible11 - Type Refl.GetTypeCode(),ction, Late Binding,292–293and Attribute-Based Programming
Part FourIConvertible- Leveraging.ToXXXX()the .NET Librarimembers, 291–292
Chapter System12 - Object.ConvertS ializationtype, 293and the .NET Remoting Layer
IDataAdapter,848
Chapter 13 - Building a Better Window (Introducing Windows Forms)
IDataParameter,846–847
Chapter 14 - A Better Painting Framework (GDI+)
IDataReader,848–850
Chapter 15 - Programming with Windows Forms Controls
IDataRecord,848–850
Chapter 16 - The System.IO Namespace
IDbCommand,846–847
Chapter 17 - Data Access with ADO.NET
IDbConnection and IDbTransaction, 846
Part Five - Web Applications and XML Web Services
IDbDataAdapter,848
Chapter 18 - ASP.NET Web Pages and Web Controls
IDbDataParameter,846–847
Chapter 19 - ASP.NET Web Applications
IDisposable,264–265
Chapter 20 - XML Web Services
IEnumerable,1005
Index
ILease,591
List of Figures
IMessage,557
List of Tables
IMessageFilter,620
implementing with VS .NET, 288–290
invoking interface members at object level, 277–279 explicit casting, 277–278
is keyword, 279 as keyword, 278 ISerializable,550–551
ISite,622
ISponsor,596
multiple base interfaces, 287–288 shapes hierarchy, 279–281 System.Collections interfaces, 306–310
System.ComponentModel.IComponent,790
System.Data.IDbTransaction,846
interfaces and collections, 273–306
Interlocked type, 492–493
C# and the .NET Platform, Second Edition
internal and public types, 184–186 |
ISBN:1590590554 |
by Andrew Troelsen |
|
internal keyword,Apress185 © 2003 (1200 pages) |
|
intrinsic C# operators,This comprehensive381–383 text starts with a brief overview of the C# language and then quickly moves to key technical and
intrinsic CTS data types, 22–23
architectural issues for .NET developers.
invocations asynchronous,1093–1094
Table of Contents synchronous,1092–1093
C# and the .NET Platform, Second Edition
IPointy interface, 273–274,279,282,284–285
Introduction
is-a and has-a relationships, 187–189,201–203,207–210,222
Part One - Introducing C# and the .NET Platform
Chapteris keyword,1 - 223The–Philosophy224,279 of .NET
Chapter 2 - Building C# Applications
is operator, 140
Part Two - The C# Programming Language
ISerializable interface, 550–551
Chapter 3 - C# Language Fundamentals
ISite interface, 622
Chapter 4 - Object-Oriented Programming with C#
ChaISponsorter 5 interface,- Exceptions596and Object Lifetime
Chapter 6 - Interfaces and Collections
IsPostBack property, 981–982
Chapter 7 - Callback Interfaces, Delegates, and Events iteration constructs, C#, 134–137
Chapter 8 - Advanced C# Type Construction Techniques foreach/in loop, 135–136
Part Three - Programming with .NET Assemblies
for loop, 135
Chapter 9 - Understanding .NET Assemblies
while and do/while looping constructs, 136–137
Chapter 10 - Processes, AppDomains, Contexts, and Threads
IUnknown interface, 396
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
J |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
jagged arrays, 157 |
|
architectural issues for .NET developers.
Java/J2EE programming, 4–5
Java Virtual Machine (JVM), 25
Table of Contents
JavaScript
C# and the .NET Platform, Second Edition
classic ASP and, 950
Introduction
for client-side code, 944–945
Part One - Introducing C# and the .NET Platform
Http requests and, 1010
Chapter 1 - The Philosophy of .NET
JIT (just-in-time) compiler. Seejitter
Chapter 2 - Building C# Applications
PartjitterTwo(just--Thein-timeC# Programmingcompiler), 18Language
Chapter 3 - C# Language Fundamentals
JScript .NET language, 409,944
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
K |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
key cryptography, public/private, 431 |
|
architectural issues for .NET developers.
Keyboard events, 631–633
KeyEventArgs type, 619
Table of Contents
KeyUp event, 631
C# and the .NET Platform, Second Edition
keywords, summary of C#, 367–369
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
L |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
last chance exceptions, 251 |
|
architectural issues for .NET developers.
late binding
dynamic invocation, 517–520
Tablereflectionof Contentsand custom attributes (example), 528–534
C# andtechnique,the .NET189Platform, Second Edition
Introduction
LayoutMdi() method, 667
Part One - Introducing C# and the .NET Platform
leading values (font metrics), 698
Chapter 1 - The Philosophy of .NET
leasing
Chapter 2 - Building C# Applications
default behavior, 590–592
Part Two - The C# Programming Language
lease adjustment
Chapter 3 - C# Language Fundamentals
client-side,595
Chapter 4 - Object-Oriented Programming with C# server-side,594–595
Chapter 5 - Exceptions and Object Lifetime
lease characteristics, altering default, 593–594
Chapter 6 - Interfaces and Collections
life-cycle of Windows Form type, 640–643
Chapter 7 - Callback Interfaces, Delegates, and Events
Form lifetime events, 640–641
Chapter 8 - Advanced C# Type Construction Techniques
Form lifetime example, 642–643
Part Three - Programming with .NET Assemblies
line numbers, altering, 87–88
Chapter 9 - Understanding .NET Assemblies
ChapterLinearGradientBrush10 - Processes,type,AppDomains,719–720Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
LineCap enumeration, 711–712
Part Four - Leveraging the .NET Libraries
ListBox controls, 992
Chapter 12 - Object Serialization and the .NET Remoting Layer
ListBoxes and ComboBoxes, 761–763
Chapter 13 - Building a Bett r Window (Introducing Windows Forms)
Chapterlistener14(server)- A Betterapplications,Painting Framework567 (GDI+)
Chapter 15 - Programming with Windows Forms Controls literals, string, 503–504
Chapter 16 - The System.IO Namespace
Load events, 641–642,978–979
Chapter 17 - Data Access with ADO.NET
LoadFrom() method, 513
Part Five - Web Applications and XML Web Services
ChapterLock() 18and-Unlock()ASP.NET methods,W b Pages1037and ,Web1043Controls
Chapter 19 - ASP.NET Web Applications
lock keyword, 490–492,492
Chapter 20 - XML Web Services
logical and physical views, 401–402
Index
loops
List of Figures
for,135
List of Tables foreach/in,135–136
while and do/while looping constructs, 136–137
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
M |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
machine-wide configuration file, 445–446 |
|
architectural issues for .NET developers.
machine.config file, 445
Main() method
Table of Contents variations on, 94–95
C# and the .NET Platform, Second Edition
Main window, building (Windows Forms), 610–612
Introduction
managed code, defined, 9
Part One - Introducing C# and the .NET Platform
Chaptermanaged1 heaps,- The Philosophy257–259 of .NET
Chapter 2 - Building C# Applications
managed providers. SeeData Providers
Part Two - The C# Programming Language
manifests
Chapter 3 - C# Language Fundamentals assembly,397,400,415
Chapter 4 - Object-Oriented Programming with C# defined,12
Chapter 5 - Exceptions and Object Lifetime manifest CIL tokens, 417
Chapter 6 - Interfaces and Collections
MappingType enumeration values, 857
Chapter 7 - Callback Interfaces, Delegates, and Events
MarshalByRefObject,622
Chapter 8 - Advanced C# Type Construction Techniques
PartmarshalingThree - Programmingobjects. See withalsoMBR.NET;AssembliesMBV,560–563
Chapter 9 - Understanding .NET Assemblies
MBR (marshal-by-reference) objects
Chapter 10 - Processes, AppDomains, Contexts, and Threads
activation of, 563–566
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
MBR configuration options, 566
Part Four - Leveraging the .NET Libraries
WKO types, configuration of, 565
Chapter 12 - Object Serialization and the .NET Remoting Layer
configuring,562–563
Chapter 13 - Builandingfundamentals,Better Window (Introducing Windows Forms)
definition 560–561
Chapter 14 - A Better Painting Framework (GDI+)
MBV (marshal-by-value) objects
Chapter 15 - Programming with Windows Forms Controls configuring,561–562
Chapter 16 - The System.IO Namespace definition and fundamentals, 560–561
Chapter 17 - Data Access with ADO.NET working with, 582–587
Part Five - Web Applications and XML Web Services
Cars general assembly, building, 583–584
Chapter 18 - ASP.NET Web Pages and Web Controls client assembly, building, 585–587
Chapter server19 - ASPassembly,.NET Webbuilding,Applications584–585
Chapter 20 - XML Web Services
MC++
Index
programming language, 413–414
List of Figures
subclass, building, 412–415
List of Tables
MDI applications, building, 666–669 child Form, 668
child windows, 668–669 parent Form, 666–667
member variable initialization syntax (C#), 104–105
MemberwiseClone() method, 297,299
MemoryStreams,820–821
menus
building with VS .NET, 654–655 building with Windows Forms, 644–646
Menu type members, 645 Menu$MenuItemCollection type, 645–646 nested MenuItemCollection type, 646
MenuItem type properties, 645–646,651–653
Menu$MenuItemCollection type, 645–646
C# and the .NET Platform, Second Edition |
|
merging (MDI applications), 666 |
ISBN:1590590554 |
by Andrew Troelsen |
|
selection prompts, 659–660 |
|
Apress © 2003 (1200 pages) |
|
system, building, 646–649 |
|
This comprehensive text starts with a brief overview of the
messages
C# language and then quickly moves to key technical and
<message> element (WSDL), 1081
architectural issues for .NET developers. message objects, defined, 557
MessageName property, 1074–1075
Tableandof Contentsproxies (.NET Remoting), 556–557
C# and the .NET Platform, Second Edition
metadata
Introduction
.NET type, 16–17
Part andOne SqlCommandBuilder,- Introducing C# the913.NET Platform
Chaptertype,1397- The,399Philosophy,499–504 of .NET
Chapterviewing2 -assembly,Building C#37Applications–38
Part Two - The C# Programming Language
metalanguages,16
Chapter 3 - C# Language Fundamentals
method parameters
Chapter 4 - Object-Oriented Programming with C# enumerating,514–515
Chapter 5 - Exceptions and Object Lifetime modifiers,147–154
Chapter 6 - Interfaces and Collections
C#out keyword, 148–149
Chapter 7 - Callback Interfaces, Delegates, and Events
C#params keyword, 150–151
Chapter 8 - Advanced C# Type Construction Techniques
C#ref keyword, 149–150
Part Three - Programming with .NET Assemblies
default parameter passing behavior, 148
Chapter 9 - Understanding .NET Assemblies
passing reference types by reference and value, 152–154
Chapter 10 - Processes, AppDomains, Contexts, and Threads
methods
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
and attributes, defined, 179,184
Part Four - Leveraging the .NET Libraries
invoking asynchronously, 343–344
Chapter 12 - Object Serialization and the .NET Remoting Layer
method access modifiers, 141–143
Chapter 13 - Building a Better Window (Introducing Windows Forms)
method hiding, 220
Chapter 14 - A Better Painting Framework (GDI+)
method overloading, 181–182
Chapter 15 - Programming with Windows Forms Controls method overriding, 220
Chaptermethod16 - visibility,The System185.IO Namespace
ChapterMethodInfo17 - Data.GetParameters()Access with ADOmethod,.NET 514–515
Part parametersFive - W b Applications.SeemethodandparametersXML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
metrics, font, 697–698
Chapter 19 - ASP.NET Web Applications
MFC (Microsoft Foundation Classes), 25
Chapter 20 - XML Web Services
MFC runtime library, 25
Index
ListMicrosoftof FiguresAccess, 886
List of Tables
Mobile Forms, 607–608
mobile .NET development,61
Mobile .NET (Ferguson, Apress), 608
modules defined,13,400,419
moduleand assemblylevel attributes, 526–527 module set, 460–461
MonthCalendar Control, 763–766
Mouse events
MouseEventArgs parameter, 619 MouseEventArgs type properties, 629 responding to, 628–631
Up, Down, and Move events, 723–728
mscoree.dll assembly, 26–27
C# and the .NET Platform, Second Edition
mscorlib.dll,48,805 |
ISBN:1590590554 |
|
|
by Andrew Troelsen |
|
MSDN online help,Apress76 © 2003 (1200 pages) |
|
|
|
This comprehensive text starts with a brief overview of the |
|
MulticastDelegate type, 328–329 |
|
|
multicasting |
C# language and then quickly moves to key technical and |
|
architectural issues for .NET developers. |
|
with .NET delegates, 332
with Car.CarDelegate (example), 338–339
Tabledefined,of Contents329
C#multidimensionaland the .NET P atform, Second Edition arrays, 156–157
Introduction
multifile assemblies
Part One - Introducing C# and the .NET Platform
building,419–422
Chapter 1 - The Philosophy of .NET
airvehicles.dll,422
Chapter 2 - Building C# Applications
ufo.netmodule,421–422
Part Two - The C# Programming Language
and single file assemblies, 13
Chapter 3 - C# Language Fundamentals
using,422–424
Chapter 4 - Object-Oriented Programming with C# multiple base classes, 204
Chapter 5 - Exceptions and Object Lifetime
multiple base interfaces, 287–288
Chapter 6 - Interfaces and Collections
Chaptermultiple7 event- Callbacksinks,Interfaces,349 352 Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques multiple exceptions, handling, 247–250
Part genericThree - Programmingcatch statements,with .249NET Assemblies
Chaptrethrowingr 9 - Understandingexceptions, 249.NET–250Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads multiple external assemblies, referencing (csc.exe), 50
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
multiple inheritance (MI), 204
Part Four - Leveraging the .NET Libraries
multiple result sets, 896
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapmultipleer 13sort- Builordersing (comparableBetter Windowobjects),(Introducing304–305Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+) multiple source files, compiling (csc.exe), 49–50
Chapter 15 - Programming with Windows Forms Controls
multitabled DataSets, filling, 916–919
Chapter 16 - The System.IO Namespace
multithreaded programming, 475–476
Chapter 17 - Data Access with ADO.NET
PartMyPluggableAppFive - W A plications.exe,530 and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
MyThreadSafeObject class type, 471
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
N |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
names |
C# language and then quickly moves to key technical and |
|
architectural issues for .NET developers. |
|
clashes, resolving across namespaces, 173–174 method,325
Tablenamespacesof Contents
C# and*.Binarythe .NETandPlatf*.Soap,rm,544Second Edition
.NET Remoting, 555
Introduction
ADO.NET,850–851
Part One - Introducing C# and the .NET Platform
aliases, defining, 174
Chapter 1 - The Philosophy of .NET
ASP.NET Web pages, 952–953
Chapter 2 - Building C# Applications
default namespace of VS .NET, 175–176
Part Two - The C# Programming Language
defining custom, 171–176
Chapter 3 - C# Language Fundamentals
GDI+ (Graphics Device Interface), 671–772
Chapter 4 - Object-Oriented Programming with C#
GUI namespaces, 607–608
Chapter 5 - Exceptions and Object Lifetime name clashes, resolving across, 173–174
Chapter 6 - Interfaces and Collections nested,174–175
Chapter 7 - Callback Interfaces, Delegates, and Events nomenclature, increasing, 33–39
Chapter 8 - Advanced C# Type Construction Techniques
Class Viewer Web application, 38
Part Three - Programming with .NET Assemblies
ildasm.exe, dumping CIL instructions to file, 36–37
Chapter 9 - Understanding .NET Assemblies
ildasm.exe, dumping namespace info to file, 35–36
Chapter 10 - Processes, AppDomains, Contexts, and Threads ildasm.exe tree view icons, 33–35
Chapter 11 - Type Reflection, Late Binding,metadata,nd Attribute-Based Programming
ildasm.exe, viewing assembly 37–38
Part Fourwincv- Leveraging.exe desktopthe .application,NET Libraries39
Chapteroverview,12 - Object28–32Serialization and the .NET Remoting Layer
Chapter accessing13 - Buildinamespacesg Better Windprogrammatically,w (Introducing Windows30–32 Forms)
Chapter referencing14 - A BetterexternalPaintingassemblies,Fra ework (GDI+)32
Chapter sampling,15 - Programming29–30 with Windows Forms Controls
Remoting (.NET), 554–555
Chapter 16 - The System.IO Namespace
System.Configuration,446–447
Chapter 17 - Data Access with ADO.NET
System.Data,845,850,851–852
Part Five - Web Applications and XML Web Services
System.Data.Common,850
Chapter 18 - ASP.NET Web Pages and Web Controls
System.Data.Odbc,851
Chapter 19 - ASP.NET Web Applications
System.Data.OleDb,851,888
Chapter 20 - XML Web Services
System.Data.OracleClient,851
Index
System.Data.SqlClient,851,887
List of Figures
System.Data.SqlServerCe,851
List of Tables
System.Data.SqlTypes,851,907
System.Drawing,673–675
System.IO.See alsoSystem.IO namespace,540
System.Resources,733–737
System.Runtime.Serialization,549
System.Runtime.Serialization.Formatters,544
System.Web,953
System.Web core types, 1031
System.Web.Services.Description,1084
System.Web.UI.HtmlControls,941
System.Web.UI.MobileControls,607
System.Web.UI.WebControls,607,984
System.Windows.Forms,608,644,693
System.Xml.Serialization,1099
XML Web services, 1064
naturally dirty windows, 682
C# and the .NET Platform, Second Edition
nested ControlCollection members, 745–746 |
ISBN:1590590554 |
||
by Andrew Troelsen |
|||
nested MenuItemCollectionApress © 2003type,(1200646pages) |
|
||
|
|
|
|
nested namespaces,This comprehensive174–175 text starts with a brief overview of the C# language and then quickly moves to key technical and
nested types architectural issues for .NET developers. definitions of, 211–212
delegates as, 334
Table of Contents
.NET.See also.NET, philosophy and overview
C# andadministrativethe .NET Platform, Second Edition
tool, 447–448
Introductapplicationon domain. SeeAppDomains (System.AppDomain type)
Part assembliesOne - Introducing.Seeassemblies,C# and the.NET.N Platform
Chapterbase1 class- Thelibraries,Philosophy76 of .NET
Chapter namespaces2 - Building C#for distributedApplicationsapplications, 554
Part Twoand- TheSystemC# ProgrammingnamespaceLanguagedata types, 375
Chapter threads3 - C#safetyLanguand,ge Fundamentals494
delegate types. Seedelegate types, .NET
Chapter 4 - Object-Oriented Programming with C#
exception handling. Seeexceptions
Chapter 5 - Exceptions and Object Lifetime
Framework, callbacks in, 325
Chapter 6 - Interfaces and Collections
namespaces overview, 28–39
Chapter 7 - Callback Interfaces, Delegates, and Events
.NET-aware compilers, 12–13
Chapter 8 - Advanced C# Type Construction Techniques
.NET-aware programming languages, 10
Part Three - Programming with .NET Assemblies
.NET Security (Apress, 2002), 404,1052
Chapter 9 - Understanding .NET Assemblies
Remoting layer. Seeserialization and .NET Remoting layer
Chapter 10 - Processes, AppDomains, Contexts, and Threads resource format, 732–733
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming running on non-Microsoft OS, 40–41
Part Four - Leveraging the .NET Libraries
runtime
Chapter 12 - Object Serialization and the .NET Remoting Layer
deploying,39–41
Chapter 13 - Building a Better Window (Introducing Windows Forms) metadata and, 499
Chapter 14 - A Better Painting Framework (GDI+) string format characters, 108–109
Chapter 15 - Programming with Windows Forms Controls
.NET, philosophy and overview, 3–41
Chapter 16 - The System.IO Namespace assembly manifest, 17–18
Chapter 17 - Data Access with ADO.NET base class libraries, 7–8
Part Five - Web Applications and XML Web Services
building blocks, 7
Chapter 18 - ASP.NET Web Pages and Web Controls
CIL,13–16,18
Chapter 19 - ASP.NET Web Applications
CLR,25–27
Chapter 20 - XML Web Services
CLS,23–25
IndexCTS,18–22
List of Figuresclass types, 19
List of Tablesdelegate types, 21 enumeration types, 21 interface types, 21 intrinsic data types, 22–23 structure types, 20
type members, 22 features/advantages of C#, 8–9 features of, 6–7
history of, 3–6
namespace nomenclature, 33–39 Class Viewer Web application, 38
ildasm.exe, dumping CIL instructions to file, 36–37 ildasm.exe, dumping namespace info to file, 35–36 ildasm.exe tree view icons, 33–35
ildasm.exe, viewing assembly metadata, 37–38 wincv.exe desktop application, 39
.NET binaries (assemblies) overview, 11–13
C# and the .NET Platform, Second Edition
.NET namespaces overview, 28–32
by Andrew Troelsen |
ISBN:1590590554 |
accessing namespaces programmatically, 30–32 |
|
Apress © 2003 (1200 pages) |
|
referencing external assemblies, 32 |
|
This comprehensive text starts with a brief overview of the sampling,29–30
C# language and then quickly moves to key technical and
.NET programming languages, 9–11
architectural issues for .NET developers.
.NET runtime, deploying, 39–41
.NET type metadata, 16–17
Tablenewofkeyword,Contents170,221,257–259,505
C# and the .NET Platform, Second Edition new object pointer, 258
Introduction
NextResult() method, 896
Part One - Introducing C# and the .NET Platform
ngen.exe utility, 448–449
Chapter 1 - The Philosophy of .NET
Chaptnonrectangularr 2 - Buildingimages,C# Applicahit testing,ons 729–731
Part Two - The C# Programming Language
nonstatic (instance) methods, 145
Chapter 3 - C# Language Fundamentals numerical casts, 224–225
Chapter 4 - Object-Oriented Programming with C#
numerical conversions, 386–387
Chapter 5 - Exceptions and Object Lifetime
Chaptnumericalr 6 -members,Interfaces125and–Collections126
Chapter 7 - Callback Interfaces, Delegates, and Events
NumericUpDown properties, 775
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
O |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
object-oriented programming (OOP) with C#, 179–229 |
|
architectural issues for .NET developers.
C# class defined, 179–184
method overloading, 181–182
self-reference in C#, 183–184
Table of Contents
C# encapsulation services, 191–199
C# and the .NET Platform, Second Edition
class properties, 193–195
Introduction
enforcing with accessors and mutators, 192–193
Part One - Introducing C# and the .NET Platform
internal representation of C# properties, 196–197
Chapter 1 - The Philosophy of .NET read-only/write-only properties, 197–198
Chapter 2 - Building C# Applications static properties, 198–199
Part Two - The C# Programming Language
C# inheritance support, 201–205
Chapter 3 - C# Language Fundamentals base class creation, 203–204
Chapter 4 - Object-Oriented Programming with C# multiple base classes, 204
Chapter 5 - Exceptions and Object Lifetime
C# polymorphic support, 213–222
Chapter 6 - Interfaces and Collections
abstract classes, defining, 215–216
Chapter abstract7 - Callbackmethods,Interfaces,216–220Delegates, and Events
Chapter versioning8 - AdvancedclassC#members,Type Construction220–222Techniques
Part castingThree - Programmingbetween classwithtypes,.NET222Assemblies–225
Chapter numerical9 - Understandingcasts, 224.NET–225Assemblies
Chapter type10 -ofProcesses,employee,AppDomains,determining,Contexts,223–224and Threads
class definitions, generating with VS .NET, 225–229
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Add Class Wizard, 225–228
Part Four - Leveraging the .NET Libraries
adding members to types, 228–229
Chapter 12 - Object Serialization and the .NET Remoting Layer
default public interface of a type, 184–186
Chapter 13 - Building a Better Window (Introducing Windows Forms)
nested type definitions, 211–212
Chapter 14 - A Better Painting Framework (GDI+)
pillars of, 186–191
Chapter 15 - Programming with Windows Forms Controls
encapsulation services, 187
Chapter 16 - The System.IO Namespace inheritance,187–189
Chapter 17 - Data Access with ADO.NET polymorphism,189–191
Part Five - Web Applications and XML Web Services
protected keyword, 205–211
Chapter 18 - ASP.NET Web Pages and Web Controls containment/delegation,207–211
Chapter 19 - ASP.NET Web Applications sealed classes, 205–207
Chapter 20 - XML Web Services read-only fields, 199–201
Index objects
List of Figures
configuring for serialization, 541–545
List of Tables
construction basics, 97–100 defined,97
as event sinks, 353–354 generations
defined,267
programmatically interacting with, 270–272 MBR.SeeMBR (marshal-by-reference) objects MBV.SeeMBV (marshal-by-value) objects object browser utility, 73
object fields and accessor methods, 563 object graphs, 260,540–541
object lifetime, 257
Object.Equals() and Object.ReferenceEquals(), 122 persistence in .NET Framework, 540 serialization.Seeserialization and .NET Remoting layer WKO types, 565
OLE/COM Object Viewer utility (Oleview.exe), 38
C# and the .NET Platform, Second Edition
OLE DB providers, 889 |
ISBN:1590590554 |
|
by Andrew Troelsen |
||
OleDb data providerAp .essSee© Data2003 (1200Providerspag s) |
|
|
|
|
|
OleDbCommandThis comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and executing stored procedures with, 899–901
architectural issues for .NET developers. inserting, updating, deleting records with, 897–899
OleDbCommand.ExecuteNonQuery() method, 897–898
OleDbCommand.ExecuteReader() method, 895–896
Table of Contents
C#OleDbConnectionand the .NET Platform,types,Second888–890Edition
Introduction
OleDbDataAdapter type, 901–905
Part columnOne - Introducingnames, alteringC# andwith,the .904NET–Platform905
Chaptercore1members- The Philosophyof, 903 of .NET
ChapterDataSets,2 - Bufillingdingwith,C# Applications903–904
Part OleDbDataAdapterTwo - The C# Programming.Fill() method,Language901–902
Chapter 3 - C# Language Fundamentals
OleDbDataReader,894–896
Chapter 4 - Object-Oriented Programming with C#
Command Behavior, 895–896
Chapter 5 - Exceptionssets,and Objectwith,L fetime multiple result obtaining 896
ChapterOleDbDataReader6 - Interfaces .andGetTableSchema()Collections method, 896
Chapterschema7 - information,Callback Interfaces,obtainingDelegates,with, 896and Events
Chapter 8 - Advanced C# Type Construction Techniques
OleDbParameter type, 899–901
Part Three - Programming with .NET Assemblies
[OneWayAttribute] type, 604–605
Chapter 9 - Understanding .NET Assemblies
OnKeyUp() method, 631
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterOnMouseMove(),11 - Type Reflection,630 Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
OnMouseUp(),630
Chapter 12 - Object Serialization and the .NET Remoting Layer
OnPaint() virtual method, 680–681,683
Chapter 13 - Building a Better Window (Introducing Windows Forms)
OnStart(),599
Chapter 14 - A Better Painting Framework (GDI+)
ChapterOnStop(),15 599- Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Open() method (FileInfo class), 815–817
Chapter 17 - Data Access with ADO.NET
OpenRead(), OpenWrite() members (FileInfo class), 817
Part Five - Web Applications and XML Web Services
OpenText(), CreateText(), AppendText() members (FileInfo class), 817–818
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapteroperating19 systems,- ASP.NETnonWeb-Microsoft,Applications40
Chapter 20 - XML Web Services
operator keyword, 376–377
Index
operator-to-CIL special name roadmap, 381–383
List of Figures
operators
List of Tables
–>,364
-> pointer-centric operator, 360 !=,378–379
* and &, 363 +,375
+= and –+, 385–386
<, >, <=, and >+, 379–380 ==,378–379
C# operators, complete set, 139–140 explicit conversion for square type, 389–390
internal representation of overloaded, 380–383 intrinsic C#, 381–383
overloadable,385
overloaded from overloaded-operator-challenged languages, 383–385 overloading,375–380
comparison operators, 379–380
C# and the .NET Platform, Second Edition |
|
equality operators, 378–379 |
ISBN:1590590554 |
by Andrew Troelsen |
|
pointer-centric operators, 360 |
|
Apress © 2003 (1200 pages) |
|
valid overloadable, 385 |
|
This comprehensive text starts with a brief overview of the
ORPC (Object Remote Procedure Call), 558
C# language and then quickly moves to key technical and
architectural issues for .NET developers. out and ref parameters, 327
out keyword, 148–149
Tableoutputof Contents
options, csc.exe, 46
C# and the .NET Platform, Second Edition
parameters,104,148–149
Introduction
PartoverflowOne -andI troducingunderflow,C# and356,the358.NET Platform
Chapter 1 - The Philosophy of .NET overloadable operators, 385
Chapter 2 - Building C# Applications
overloaded operators
Part Two - The C# Programming Language
C#,329,332,351
Chapter 3 - C# Language Fundamentals
from overloaded-operator-challenged languages, 383–385
Chapter 4 - Object-Oriented Programming with C#
overloading
Chapter 5 - Exceptions and Object Lifetime
method,181–182
Chapter 6 - Interfaces and Collections
operators,375–380
Chapter 7 - Callback Interfaces, Delegates, and Events
comparison operators, 379–380
Chapter 8 - Advanced C# Type Construction Techniques equality operators, 378–379
Part Three - Programming with .NET Assemblies
overriding
Chapter 9 - Understanding .NET Assemblies
defined,118
Chapter 10 - Processes, AppDomains, Contexts, and Threads
override keyword, 214,218
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index
P
Page class, 975
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
<%@Page%> directive, 955
Page type, properties of, 971
Table of Contents
paging, enabling (DataGrids), 1000–1001
C# and the .NET Platform, Second Edition
painting
Introduction
basics,635–636
Part One - Introducing C# and the .NET Platform
paint handler, 682–683
Chapter 1 - The Philosophy of .NET
paint sessions, 680–684
Chapter 2 - Building C# Applications
client area, invalidating, 682
Part Two - The C# Programming Language
obtaining graphics type, 682–684
Chapter 3 - C# Language Fundamentals
PaintEventArgs properties, 635
Chapter 4 - Object-Oriented Programming with C#
Panel Controls, 773
Chapter 5 - Exceptions and Object Lifetime
Chpanes,pter 6defined,- Interfaces655 and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
parameters
Chapter 8 - Advanced C# Type Construction Techniques
interfaces as, 280–281
Part Three - Programming with .NET Assemblies
parameter modifiers, 147
Chapter 9 - Understanding .NET Assemblies
parameter passing behavior, 148
Chapterparameterized10 - Processes,constructors,AppD mains,20 Contexts, and Threads
Chapterparameterized11 - Type Reflqueries,ction,898Late–899Binding,908and Attribute-Based Programming
Part paramsFour - Leveragingkeyword, 150the –.NET151Libraries
Chaptertaking12 delegates- Object Serializationas, 334 and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms) parent Form, building (MDI applications), 666–667
Chapter 14 - A Better Painting Framework (GDI+) parsing values from string data, 127–128
Chapter 15 - Programming with Windows Forms Controls
passing reference types, 152–154
Chapter 16 - The System.IO Namespace
Chapterpen caps,17 -711Data–713Access with ADO.NET
Part Five - Web Applications and XML Web Services
pen objects, 707–711
Chapter 18 - ASP.NET Web Pages and Web Controls
persistent cookies, defined, 1047
Chapter 19 - ASP.NET Web Applications
physical and logical views, 401–402
Chapter 20 - XML Web Services
IndexPictureBox control, 723–727
List of Figures
PictureBoxSizeMode enumeration, 724
List of Tables
pillars of OOP, 186–191 encapsulation services, 187 inheritance,187–189 polymorphism,189–191
Point objects, adding and subtracting, 376–377
point of origin, 690–692
pointer-centric operators, 360
pointers
field access via, 364 new object, 258
Point(F) type, 675–676
policies
custom version, 440 publisher policy, 444–445
polymorphism
C# and the .NET Platform, Second Edition |
|
C# polymorphic support, 213–222 |
ISBN:1590590554 |
by Andrew Troelsen |
|
abstract classes, defining, 215–216 |
|
Apress © 2003 (1200 pages) |
|
abstract methods, 216–220 |
|
This comprehmembers,nsive text starts with a brief overview of the versioning class 220–222
C# language and then quickly moves to key technical and classical and ad hoc, 189–191
architectural issues for .NET developers. enforcing polymorphic activity, 216–220
interfaces as polymorphic agents, 284–285
Tablepop-ofupContentsmenus, creating, 649–651
C# and the .NET Platform, Second Edition
<portType> element (WSDL), 1081
Introduction
POST and GET methods, 947,949–950
Part One - Introducing C# and the .NET Platform
POST messages, HTTP, 1087
Chapter 1 - The Philosophy of .NET
Chappostbacks,er 2 -944Building,981 C# Applications
Part Two - The C# Programming Language
prejitted configuration, 448
Chapter 3 - C# Language Fundamentals preprocessing messages, 619–621
Chapter 4 - Object-Oriented Programming with C#
preprocessor directives, C#, 82–88
Chapter 5 - Exceptions and Object Lifetime
altering line numbers, 87–88
Chapter 6 - Interfaces and Collections
conditional code compilation, 84–86
Chapter 7 - Callback Interfaces, Delegates, and Events
issuing warnings and errors, 86
Chapter 8 - Advanced C# Type Construction Techniques specifying code regions, 83–84
Part Three - Programming with .NET Assemblies
primary key constraint, 855
Chapter 9 - Understanding .NET Assemblies
Chapterprimary10modules,- Processdefined,s, AppDomains,13 419 Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming primary threads, defined, 452
Part Four - Leveraging the .NET Libraries
PrimaryKey property, 864–865
Chapter 12 - Object Serialization and the .NET Remoting Layer
private and public methods, 142
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapterprivate14assemblies,- A Better511Painting–515Framework (GDI+)
Chapterenumerating15 - Pro rammingclass members,with Windows513–514Forms Controls
Chapterenumerating16 - The Systemmethod.IOparameters,N espace514–515
enumerating types in referenced assemblies, 513
Chapter 17 - Data Access with ADO.NET
fundamentals of, 425
Part Five - Web Applications and XML Web Services
identity of, 426
Chapter 18 - ASP.NET Web Pages and Web Controls
probing for, 425–426,429–430
Chapter 19 - ASP.NET Web Applications
and XML configuration files, 426–429
Chapter 20 - XML Web Services
Indexprivate data fields, 192
List of Figures
private key, defined, 431
List of Tables
private keyword, 185,191
probing for private assemblies, 425,429–430
process identifiers (PIDs), 451
processes AppDomain,474–475 defined,451
interaction under .NET, 453–462 enumerating running processes, 456–457 module set, investigating, 460–461 specific process, investigating, 457
starting and killing programmatically, 461–462 System.Diagnostics namespace members, 454–456 thread set, investigating, 458–460
ProcessExit event, 468
Process.GetProcessById() method, 457
Process.GetProcesses() method, 456
C# and the .NET Platform, Second Edition |
|
ProcessStartInfo type definition, 462 |
ISBN:1590590554 |
by Andrew Troelsen |
|
ProcessThread type members, 459–460 |
|
Apress © 2003 (1200 pages) |
|
and threads under Win32, 451–453 |
|
This comprehensive text starts with a brief overview of the program constants, defining, 132–134
C# language and then quickly moves to key technical and programming architectural issues for .NET developers.
attributed,520–522
languages, .NET, 9–11,944,950
Table of Contents
multithreaded via delegates, 476
C# and the .NET Platform, Second Edition
with TimerCallbacks, 494–496
Introduction
with Windows Forms Controls. SeeWindows Forms Controls, programming with
Part One - Introducing C# and the .NET Platform
project solution, creating VS .NET, 60–61
Chapter 1 - The Philosophy of .NET
project-wide symbols, setting, 86
Chapter 2 - Building C# Applications
PapropertiesTwo - The C# Programming Language
Chapter.NET3 classes- C# Languagedefining,Fundamentals193
defined,184
Chapter 4 - Object-Oriented Programming with C#
internal representation of, 196–197
Chapter 5 - Exceptions and Object Lifetime
properties window, 66
Chapter 6 - Interfaces and Collections
Property Builder Wizard, 1000
Chapter 7 - Callback Interfaces, Delegates, and Events
PropertyCollection type, 874
Chapter 8 - Advanced C# Type Construction Techniques
read-only and write-only, 197–198
Part Three - Programming with .NET Assemblies
and sort types, custom, 306
Chapter 9 - Understanding .NET Assemblies static,198–199
Chapter 10 - Processes, AppDomains, Contexts, and Threads
protected internal keywords, 185,191
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PaprotectedFour - Lkeyword,veraging205the–211.NET Libraries
Chaptercontainment/delegation,12 - Object Serializationprogrammingand the .NETfor,Remoting207–211Layer Chapterencapsulation13 - Bu ldingenforceda Betterwith,Window191(Introducing Windows Forms)
sealed classes, 205–207
Chapt r 14 - A Better Painting Framework (GDI+)
visibility levels and, 185
Chapter 15 - Programming with Windows Forms Controls Chapterproxies16 - The System.IO Namespace Chapterbasics,17 1060- Data Access with ADO.NET
Part generating,Five - Web Applications1089–1091,1095and XML Web Services
Chapterand18messages- ASP.NET(.NETWeb Remoting),Pages and Web556Controls–557
proxy code, 1089–1091
Chapter 19 - ASP.NET Web Applications
proxy logic, hard-coded, 1094
Chapter 20 - XML Web Services
Indexpublic and internal types, 184–186
List of Figures
public and private methods, 142
List of Tables
public field data, defined, 184
public interface, default, 184–186
public key, defined, 431
public keywords, 94,185,191
publisher policy assemblies,444–445 disabling,445
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
Q |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
Query Analyzer utility (SQL Server), 886 |
|
architectural issues for .NET developers.
QueryString property (HttpRequest), 975
Queue class type, 310,312–313
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
R |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
RadioButtons |
C# language and then quickly moves to key technical and |
|
|
|
architectural issues for .NET developers. and GroupBoxes, 756–760
CheckedListBox Control, 758–760
example,756–758
Table of Contents
types,992–993
C# and the .NET Platform, Second Edition
Random.Next() method, 143
Introduction
PartRangeValidators,One - Introducing1008C#–1009and the .NET Platform
Chapter 1 - The Philosophy of .NET
Read() method, 895
Chapter 2 - Building C# Applications
read-only and write-only properties, 197–198
Part Two - The C# Programming Language
Chapterread-only3 fields,- C# Language199–201Fundamentals
Chapter 4 - Object-Oriented Programming with C# readonly keyword, 192,199–200
Chapter 5 - Exceptions and Object Lifetime
ReadOnly member, 835
Chapter 6 - Interfaces and Collections
ReadXml() method, 884
Chapter 7 - Callback Interfaces, Delegates, and Events
ReadXmlSchema() method, 885
Chapter 8 - Advanced C# Type Construction Techniques
PartrealThreeproxies,- Programming557 with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
records
Chapter 10 - Processes, AppDomains, Contexts, and Threads
inserting, updating, deleting with OleDbCommand, 897–898
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
inserting with SqlDataAdapter, 907–910
Part Four - Leveraging the .NET Libraries
updating with SqlDataAdapter, 910–912
Chapter 12 - Object Serialization and the .NET Remoting Layer
Rectangle(F) type, 677–678
Chapter 13 - Building a Better Window (Introducing Windows Forms)
rectangular arrays, 156
Chapter 14 - A Better Painting Framework (GDI+)
Chaptredirectingr 15 -usersProgramming(HttpResponsewith Windows.Redirect),Forms977Controls–978
Chapter 16 - The System.IO Namespace
ref and out parameters, 327–328
Chapter 17 - Data Access with ADO.NET ref keyword, 149–150,364
Part Five - Web Applications and XML Web Services
reference books
Chapter 18 - ASP.NET Web Pages and Web Controls
Advanced .NET Remoting (Apress, 2002), 560
Chapter 19 - ASP.NET Web Applications
Distributed .NET Programming in C# (Apress, 2002), 567,606
Chapter 20 - XML Web Services
Essential Guide to Managed Extensions for C++ (Apress, 2002), 413–414
Index
GDI+ Programming in C# and VB .NET (Apress, 2002), 742
List of Figures
Mobile .NET (Ferguson, Apress), 608
List of Tables
.NET Security (Apress, 2002), 404,1052
A Programmer's Guide to ADO.NET in C# (Apress, 2002), 931
User Interfaces in C# (Apress, 2002), 802
VB .NET and the .NET Platform (Apress, 2002), 412
Writing Add-Ins for VS .NET (Apress, 2002), 534
references
obtaining interface, 277–279
reference-based and value-based types, 109–114 comparison of, 113–114
value types containing reference types, 112–113 reference parameters, 149–150
reference semantics, 118 reference types
passing by reference and value, 152–154 and value types, converting between, 128–132
referenced assemblies, 513
C# and the .NET Platform, Second Edition
reflection |
ISBN:1590590554 |
by Andrew Troelsen |
defined,504 Apress © 2003 (1200 pages)
late binding and custom attributes example, 528–534
This comprehensive text starts with a brief overview of the
C# snap-in, building, 531
C# language and then quickly moves to key technical and
common snappable types, building, 530 architectural issues for .NET developers.
custom snap-in consumer, building, 529–530
extendible Windows Forms application, building, 532–534
Table ofVBContents.NET snap-in, 531–532
C# and the .NET Platform, Second Edition
Refresh() method, 808
Introduction
#region and #endregion tags, 83
Part One - Introducing C# and the .NET Platform
Region class, 678–679
Chapter 1 - The Philosophy of .NET
ChapterRegularExpressionValidator,2 - Building C# Applications1008
Part Two - The C# Programming Language
related tables navigation, 880–883
Chapter 3 - C# Language Fundamentals relational and equality operators, 137
Chapter 4 - Object-Oriented Programming with C#
Relations property, 874
Chapter 5 - Exceptions and Object Lifetime
Chapterremote6objects,- Interfaceshosts andfor, 597Collection–603 s
ChapterCarService,7 - Callbackinstalling,Interfaces,601 Delegates, and Events
IIS,602–603
Chapter 8 - Advanced C# Type Construction Techniques
Main() method, ServiceBase derived, 599
Part Three - Programming with .NET Assemblies
OnStart(),599
Chapter 9 - Understanding .NET Assemblies
OnStop(),599
Chapter 10 - Processes, AppDomains, Contexts, and Threads
service installer, 600–601
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Windows service, 597–598
Part Four - Leveraging the .NET Libraries
ChapterRemoteConfiguration12 - Object Serializationtype, 573and–575the .NET Remoting Layer
ChapterRemoteMessageObject13 - Building Better Window (Introducing Windows Forms)
type, 577
Chapter 14 - A Better Painting Framework (GDI+) remoting.See alsoserialization and .NET Remoting layer
Chapter 15 - Programming with Windows Forms Controls application
Chapter 16 - The System.IO Namespace building,566–567
Chapter 17 - Data Access with ADO.NET testing,571
Part Five - Web Applications and XML Web Services
architecture, default .NET, 559
Chapter 18 - ASP.NET Web Pages and Web Controls
asynchronous,603–604
Chapterconfiguration19 - ASP.NETfiles,Web579Applications–582
Chapter client20 - -XMLsideWeb*.configServicfiles, building, 581–582
Index server-side *.config files, building, 580–581
List ofdefined,Figures554
Framework, .NET, 556–559
List of Tables
.NET formatters, 559
channels,558
extending default remoting layers, 560 proxies and messages, 556–557 terminology,560
namespaces,554–555,555 remoting layers
extending default, 560
and serialization. Seeserialization and .NET Remoting layer
Remove() and RemoveAll() methods, 1046
Remove(), static, 329,339
RenamedEventHandler type, 831
rendering quality, 706–707
resgen.exe utility, 732,736
resources
C# and the .NET Platform, Second Edition configuration with VS .NET, 739–742
by Andrew Troelsen |
ISBN:1590590554 |
format, .NET, 732–733 |
|
Apress © 2003 (1200 pages) |
|
ResourceManagers,737–739 |
|
This comprehensive text starts with a brief overview of the
ResourceWriters,737
C# language and then quickly moves to key technical and response file, defaultarchitectu(csc.rsp),al issues51 for .NET developers.
Response type properties and methods (Http), 975–976
ResXResourceReader type, 733–734
Table of Contents
C#ResXResourceWriterand the .NET Platfo m,class,Second733–Edition734
Introductrethrowingon exceptions, 249–250
Part One - Introducing C# and the .NET Platform
return values, method, 325
Chapter 1 - The Philosophy of .NET
reuse, binary, 402
Chapter 2 - Building C# Applications
PartrichTwocontrols- The(WebControls),C# Programming991Language,995–997
Chapter 3 - C# Language Fundamentals
RichTextBox class, 752
Chapter 4 - Object-Oriented Programming with C# roots, application, 259
Chapter 5 - Exceptions and Object Lifetime
RowFilter property (DataViews), 873
Chapter 6 - Interfaces and Collections
Chapterrows (DataTables)7 - Cal back Interfaces, Delegates, and Events
deleting,866–867
Chapter 8 - Advanced C# Type Construction Techniques
updating,869–871
Part Three - Programming with .NET Assemblies
ChapterRTTI (Runtime9 - UnderstanType Identification),ing .NET Assemblies239
Chapter 10 - Processes, AppDomains, Contexts, and Threads running processes, 456–457
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
running vs. debugging, 71
Part Four - Leveraging the .NET Libraries
runtime
Chapter 12 - Object Serialization and the .NET Remoting Layer
.NET, deploying, 39–40
Chapter 13 - Building a Better Window (Introducing Windows Forms)
defined,25
Chapter 14 - A Better Painting Framework (GDI+)
obtaining attributes at, 528
Chapter 15 - Programming with Windows Forms Controls
runtime system, .NET (CLR), 26
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
S |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
SAO (server activated object), 564 |
|
architectural issues for .NET developers.
SaveFileDialog type, 838–839
schema information
Table of Contents defined,891
C# and the .NET Platform, Second Edition obtaining with OleDbDataReader, 896
Introduction
script blocks, 956–957
Part One - Introducing C# and the .NET Platform
scripting, client-side, 943–946
Chapter 1 - The Philosophy of .NET
default.htm form data, 946
Chapter 2 - Building C# Applications
example,945–946
Part Two - The C# Programming Language
ChapterScrollableControl3 - C# Languageclass, 636Fundamentals–637
Chapter 4 - Object-Oriented Programming with C#
SDI (Single Document Interface), 610
Chapter 5 - Exceptions and Object Lifetime
sealed classes, 205–207
Chapter 6 - Interfaces and Collections
sealed keyword, 206
Chapter 7 - Callback Interfaces, Delegates, and Events
security context defined (assemblies), 404
Chapter 8 - Advanced C# Type Construction Techniques
PartSelect()Threemethod- Programming(DataTables),with .NET867Assemblies,869
Chapter 9 - Understanding .NET Assemblies
SELECT SQL statements, 848
Chapter 10 - Processes, AppDomains, Contexts, and Threads
SelectionMode property, 995–996
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartselfFour-reference- Leveragingin C#, the183.–NET184Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer semicolon-delimited lists, 50
Chapter 13 - Building a Better Window (Introducing Windows Forms) separation of concerns, 100
Chapter 14 - A Better Painting Framework (GDI+)
serialization and .NET Remoting layer, 539–606
Chapter 15 - Programming with Windows Forms Controls
asynchronous remoting, 603–604
Chapter 16 - The System.IO Namespace basics,539
Chapter 17 - Data Access with ADO.NET binary formatter, 545–547
Part Five - Web Applications and XML Web Services
CAO,587–589
Chapter 18 - ASP.NET Web Pages and Web Controls
CAO/WKO-singleton objects, 589–595
Chapter 19 - ASP.NET Web Applications
client-side lease adjustment, 595
Chapter 20 - XML Web Services
default leasing behavior, 590–594 Index server-side lease adjustment, 594–595
List ofChannelServicesFigur s type, 572–573
List ofchoosingTables formatters, 544–545 configuring objects for, 541–545
customizing serialization process, 549–554 defined,539–540
deploying server to remote machine, 577 distributed application, building, 568–571
general assembly, 568 server assembly, 569–570
SimpleRemoteObjectClient.exe assembly, 570–571 marshaling objects, 560–563
internal optimizations, 563
MBR objects, configuring, 562–563
MBV objects, configuring, 561–562
MBR object activation, 563–566
MBR configuration options, 566
WKO types, configuration of, 565
MBV objects, 582–587
C# and the .NET Platform, Second Edition
Cars general assembly, building, 583–584
by Andrew Troelsen |
ISBN:1590590554 |
client assembly, building, 585–587 |
|
Apress © 2003 (1200 pages) |
|
server assembly, building, 584–585 |
|
This comprehensive text starts with a brief overview of the
.NET Remoting framework
C# language and then quickly moves to key technical and
.NET formatters, 559
architectural issues for .NET developers. application building, 566–567
channels,558
defining,554
Table of Contents
extending default remoting layers, 560
C# and the .NET Platform, Second Edition
namespaces,554–555
Introduction
proxies and messages, 556–557
Part One - Introducing C# and the .NET Platform
terminology,560
Chapter 1 - The Philosophy of .NET object graphs, 540–541
Chapter 2 - Building C# Applications object persistence in, 540
Part Two - The C# Programming Language
[OneWayAttribute] type, 604–605
Chapter 3 - C# Language Fundamentals remote application, testing, 571
Chapter 4 - Object-Oriented Programming with C# remote objects, hosts for, 597–603
Chapter 5 - Exceptions and Object Lifetime
CarService, installing, 601
Chapter 6 - Interfaces and Collections
IIS,602–603
Chapter Main()7 - Callbackmethod,Interfaces,ServiceBaseDelegates,derived,and599Events
Chapter OnStart(),8 - Advanced599 C# Type Construction Techniques
Part ThreeOnStop(),- Programming599 with .NET Assemblies
Chapter service9 - Understandinginstaller, 600.NET–601Assemblies
Chapter Windows10 - Processes,service,AppDomains,597–598 Contexts, and Threads
RemoteConfiguration type, 573–575
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
remoting configuration files, 579–582
Part Four - Leveraging the .NET Libraries
client-side *.config files, building, 581–582
Chapter 12 - Object Serialization and the .NET Remoting Layer
server-side *.config files, building, 580–581
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Serialize() method, 545–546
Chapter 14 - A Better Painting Framework (GDI+)
server-side/client-side lease sponsorship, 595–597
Chapter 15 - Programming with Windows Forms Controls
SOAP formatter, 547
Chapter 16 - The System.IO Namespace
TCP channel, 578–579
Chapter 17 - Data Access with ADO.NET
WKO types, 576–577
Part Five - Web Applications and XML Web Services
XML formatter, 548
Chapter 18 - ASP.NET Web Pages and Web Controls
servers
Chapter 19 - ASP.NET Web Applications
defined,554
Chapter 20 - XML Web Services
server assembly
Index
building,569–570,584–585
List of Figures defined,567
List of Tables
Server Explorer
drag and drop in, 926–927 utility,919
window,71–72 Server property, 1073 server-side
*.config files, building, 580–581
and client-side lease sponsorship, 590,595–597 event handling, 983–984
lease adjustment, 594–595 scripting languages, 950
variables,974 Web,936–938
<service> element (WSDL), 1082
service installer, 600–601
sessions
C# and the .NET Platform, Second Edition |
|
cookies, defined, 1048 |
ISBN:1590590554 |
by Andrew Troelsen |
|
data, maintaining, 1043–1046 |
|
defined,1043 Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the session state, configuring with web.config, 1077
C# language and then quickly moves to key technical and
Session State Server (ASP.NET), 1056 architectural issues for .NET developers.
session states vs. application states, 1033–1037 <sessionState>,1054–1056
Tableset_ofandContentsget methods, 196–197
C# and the .NET Platform, Second Edition
Set keyword, VB 6.0, 374
Introduction
SetStyle() method, 624
Part One - Introducing C# and the .NET Platform
Setter/Getter tokens, 502
Chapter 1 - The Philosophy of .NET
Chaptersevered2 roots,- Building260 C# Applications
Part Two - The C# Programming Language
shadow directories, 958
Chapter 3 - C# Language Fundamentals shallow copies, 297
Chapter 4 - Object-Oriented Programming with C#
shapes hierarchy (interfaces), 275–276,279–281
Chapter 5 - Exceptions and Object Lifetime
Chaptsharedr 6assemblies- Interfaces and Collections
Chapterbuilding,7 - 432Callback–434Interfaces,516–517 Delegates, and Events
fundamentals of, 430–431
Chapter 8 - Advanced C# Type Construction Techniques
installing and removing, 435–436
Part Three - Programming with .NET Assemblies
SharedAssembly, freezing current, 438
Chapter 9 - Understanding .NET Assemblies
SharedAssembly version 2.0.0.0, 438–439
Chapter 10 - Processes, AppDomains, Contexts, and Threads
using,436
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
versioning,437–438
Part Four - Leveraging the .NET Libraries
ChapterSharpDevelop12 - ObjectIDE,Serialization89 and the .NET Remoting Layer
Chapter 13 - Building attribute,Better Window (Introducing Windows Forms) shorthand notation, 524
Chapter 14 - A Better Painting Framework (GDI+) side-by-side execution (assemblies), 404
Chapter 15 - Programming with Windows Forms Controls
signing, delayed, 434–435
Chapter 16 - The System.IO Namespace
simple controls (WebControls), 991
Chapter 17 - Data Access with ADO.NET
PartSimpleRemoteObjectClientFive - Web Applications and.exe,XML568Web,570Services–571
Chapter 18 - ASP.NET Web Pages and Web Controls
SimpleRemoteObjectServer.exe,568,577
Chapter 19 - ASP.NET Web Applications
SimpleRemotingAsm.dll,568–570
Chapter 20 - XML Web Services
single file and multifile assemblies, 13,400–401
Index
Lisinglet of Figuresfile test assembly, building, 404–408
List of Tables
single-threaded applications, 341
singleton WKO types, 570,576
sinks
event sinks, 353–354 multiple event, 352 multiple event sinks, 349 sink objects, 322
Size(F) types, 678
sizeof keyword, 366–367
SmoothingMode enumeration, 706–707
snap-ins,529–532 building C#, 531
building VB .NET, 531–532
snap-in consumer, building, 529–530
snappable types, building, 530
C# and the .NET Platform, Second Edition
SnappableAttribute type, 530
by Andrew Troelsen |
ISBN:1590590554 |
sn.exe (strong name) utility, 432–433 |
|
Apress © 2003 (1200 pages) |
|
SOAP (Simple Object Access Protocol)
This comprehensive text starts with a brief overview of the formatter (serialization),C# l nguage547and,558then quickly moves to key technical and
architectural issues for .NET developers. messages,1088–1089
SoapHttpClientProtocol members, 1090
soapsuds.exe command line application, 567
Table of Contents
solid brushes, 713–715
C# and the .NET Platform, Second Edition
Introductionsolution explorer window, 62–64
Part One - Introducing C# and the .NET Platform
Solutions Explorer, 919–921
Chapter 1 - The Philosophy of .NET
Sort() method, 302
Chapter 2 - Building C# Applications
PartsortTwoorders,- ThemultipleC# Programming(comparableLanguageobjects), 304–305
Chapter 3 - C# Language Fundamentals
sort types and properties, 306
Chapter 4 - Object-Oriented Programming with C# special names from VB .NET, 384–385
Chapter 5 - Exceptions and Object Lifetime
Specialized namespace. SeeSystem.Collections.Specialized namespace
Chapter 6 - Interfaces and Collections
spin controls, 774
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterSQL (Structured8 - AdvancedQueryC#Language)Type Construction Techniques
Part commandsThree - Programming with .NET Assemblies
Chapter auto9 --generatingUnd s andingwith.NETCommandBuilderAssemblies types, 912–914
Chapter building10 - Processes,with OleDbCommand,AppD ains, Contexts,892–893and Threads
Chapterconnection,11 - Typecreating,Reflection,921Late–922Binding, and Attribute-Based Programming
Part DataFour -Provider,Le eraging906the–912.NET Libraries
SqlDataAdapter, inserting records with, 907–910
Chapter 12 - Object Serialization and the .NET Remoting Layer
SqlDataAdapter, updating records with, 910–912
Chapter 13 - Building a Better Window (Introducing Windows Forms)
System.Data.SQLTypes namespace, 907
Chapter 14 - A Better Painting Framework (GDI+)
Server,886–887,1056
Chapter 15 - Programming with Windows Forms Controls
Server Query Analyzer, 1056
Chapter 16 - The System.IO Namespace
SqlCommandBuilder,912–914
Chapter 17 - Data Access with ADO.NET
SqlConnectionString attribute, 1056
Part Five - Web Applications and XML Web Services
SqlDataAdapter, inserting records with, 907–910
Chapter 18 - ASP.NET Web Pages and Web Controls
SqlDataAdapter, updating records with, 910–912
Chapter 19 - ASP.NET Web Applications
square brackets ([ ]), 532
Chapter 20 - XML Web Services
Indexsquare type, 389–390
List of Figures
Stack class type, 310,313–314
List of Tables
stackalloc keyword, 365 StackTrace property, 239
Start() and Kill() methods, 461–462 start page, VS .NET, 58–59 StartFigure() method, 730
state management (Web applications), 1023–1026 stateConnectionString attribute, 1056
stateful Web services, building, 1075–1077 stateless wire protocols, 936
[STAThread] attribute, 67 static Combine() method, 329 static constructors, 198–199
static data, defining, 145–147
C# and the .NET Platform, Second Edition
static functions, 339–340 |
ISBN:1590590554 |
by Andrew Troelsen |
|
static keyword, 94A,press199 © 2003 (1200 pages) |
|
static level CTS members,This comprehedefined,sive22text starts with a brief overview of the
C# language and then quickly moves to key technical and static members architectural issues for .NET developers.
defined,22
of System.Object base class, 122
Table of Contents
static methods, 143–147
C# and the .NET Platform, Second Edition
defining,143–145
Introductionstatic data, defining, 145–147
Part One - Introducing C# and the .NET Platform
static properties, 198–199
Chapter 1 - The Philosophy of .NET
static read-only fields, 200–201
Chapter 2 - Building C# Applications
PartstaticTwoRemove()- The C#method,Programming329 Language
Chapter 3 - C# Language Fundamentals
static type members, 563
Chapter 4 - Object-Oriented Programming with C# statistics
Chapter 5 - Exceptions and Object Lifetime basic thread, 478–479
Chapter 6 - Interfaces and Collections obtaining browser, 973
Chapter 7 - Callback Interfaces, Delegates, and Events
Status bars, 655–660
Chapter 8 - Advanced C# Type Construction Techniques building,656–657
Part Three - Programming with .NET Assemblies
menu selection prompts, 659–660
Chapter 9 - Understanding .NET Assemblies select properties of, 655
Chapter 10 - Processes, AppDomains, Contexts, and Threads
StatusBarPanel type properties, 656
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Timer type, 658–659
Part Four - Leveraging the .NET Libraries
stored procedures, 899–901
Chapter 12 - Object Serialization and the .NET Remoting Layer
storing state with <sessionState>, 1054–1056
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapterstreams14 - A Better Painting Framework (GDI+)
Chapterabstract15 -.SeeProgrammingabstract streamwith Windowsclass Forms Controls
Chaptdefined,r 16 -818The System.IO Namespace
StreamingContextStates enumeration members, 551–552
Chapter 17 - Data Access with ADO.NET
StreamReader class, 136
Part Five - Web Applications and XML Web Services
StreamReader.Peek() method, 826
Chapter 18 - ASP.NET Web Pages and Web Controls
StreamWriters and StreamReaders, 822–826
Chapter 19 - ASP.NET Web Applications
text files, reading from, 825–826
Chapter 20 - XML Web Services Index text files, writing to, 824–825
TextWriter core members, 823–824
List of Figures
strings
List of Tables
data, parsing values from, 127–128 escape characters, 161–162 formatting flags, 107–109
literals, documenting, 503–504 manipulation in C#, 160–164
escape characters and "verbatim strings", 161–162 System.Text.StringBuilder,162–164
String.Length property, 138
StringReader type, 828–829
StringWriter type, 826–828
strong names, 431–432
structured exception handling (SEH), 233
structures
CTS types, 20
defining in C#, 168–171
C# and the .NET Platform, Second Edition
style sheets and tab order, 997 |
ISBN:1590590554 |
||
by Andrew Troelsen |
|||
subdirectories, creating,Apress ©8112003–812(1200 pages) |
|
||
|
|
|
|
switch statements,This138comprehensive–139 text starts with a brief overview of the
C# language and then quickly moves to key technical and synchronization architectural issues for .NET developers.
with C# lock keyword, 490–492 using [Synchronized] attribute, 493
Tableusingof ContentsSystem.Threading.Interlocked type, 492–493
using System.Threading.Monitor type, 491–492
C# and the .NET Platform, Second Edition
Introductionsynchronous delegate invocations, 342
Part One - Introducing C# and the .NET Platform
synchronous method invocations, 1090,1092–1093
Chapter 1 - The Philosophy of .NET
syntactic constructs, CTS-defined, 19
Chapter 2 - Building C# Applications
PartsystemTwo--andTheapplicationC# Programming-level exceptions,Language 252
Chapter 3 - C# Language Fundamentals
system attributes, predefined, 521
Chapter 4 - Object-Oriented Programming with C# system data types and C# aliases, 122–128
Chapter 5 - Exceptions and Object Lifetime basic numerical members, 125–126
Chapter 6 - Interfaces and Collections experimenting with, 125
Chapter 7 - Callback Interfaces, Delegates, and Events string data, parsing values from, 127–128
Chapter 8 - Advanced C# Type Construction Techniques
System.Boolean members, 126
Part SystemThree - .ProgCharNextammingmembers,with .NET127Assemblies
Chapter 9 - Understanding .NET Assemblies
system exceptions
Chapter 10 - Processes, AppDomains, Contexts, and Threads
and application exceptions, 244
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
debugging with VS .NET, 253–256
Part Four - Leveraging the .NET Libraries
defined,240
Chapter 12 - Object Serialization and the .NET Remoting Layer
locating,241–242
Chapter 13 - Building a Better Window (Introducing Windows Forms)
System namespaces (listed), 29–31
Chapter 14 - A Better Painting Framework (GDI+)
system types, hierarchy of, 124
Chapter 15 - Programming with Windows Forms Controls
ChapSystemr 16.Activator- The Systemclass,.IO518Namespace–519
ChaptSystemr 17 - Data Access with ADO.NET
.AppDomain type. SeeAppDomains (System.AppDomain type)
Part Five - Web Applications and XML Web Services
System.ApplicationException,243–247
Chapter 18 - ASP.NET Web Pages and Web Controls
System.Array base class, 158–159
Chapter 19 - ASP.NET Web Applications
ChapSystemr 20.Array- XMLtype,Web1005Services
Index
System.AsyncCallback,345
List of Figures
System.Boolean members, 126
List of Tables
System.CharNext members, 127
System.Collections namespace, 130,306–315 class types of, 310–314
interfaces of, 306–310 System.Collections.Specialized namespace, 314–315
System.Collections.HashTable type, 121
System.Collections.Specialized.-ListDictionary,372
System.ComponentModel namespace, 798–799
System.ComponentModel.Component,790
System.ComponentModel.IComponent interface, 790
System.Configuration namespace, 446–447
System.Console class. Seeconsole class
System.Console type, 824
System.Convert type, 293
C# and the .NET Platform, Second Edition
System.Data namespace, 845,850–852 |
ISBN:1590590554 |
by Andrew Troelsen |
|
System.Data.Common namespace, 850 |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
System.Data.Common.DataTableMapping type, 905
C# language and then quickly moves to key technical and System.Data.DataRelationrchitecturaltype,issues879for .NET developers.
System.Data.dll assembly, 851
System.Data.IDbTransaction interface, 846
Table of Contents
C#Systemand the.Data.NET.OdbcPlatform,namespace,Second Edition851
Introduction
System.Data.OleDb namespace, 851,888
Part One - Introducing C# and the .NET Platform
System.Data.OracleClient namespace, 851
Chapter 1 - The Philosophy of .NET
System.Data.OracleClient.dll assembly, 851
Chapter 2 - Building C# Applications
PartSystemTwo.-DataThe.SqlClientC# Programnamespace,ing L nguage851,887,906
Chapter 3 - C# Language Fundamentals
System.Data.SqlClient.SqlConnection type, 921
Chapter 4 - Object-Oriented Programming with C#
System.Data.SqlServerCe namespace, 851
Chapter 5 - Exceptions and Object Lifetime
System.Data.Sqlservice.dll assembly, 851
Chapter 6 - Interfaces and Collections
ChapSystemr 7.Data- Callback.SqlTypesInterfaces,namespace,Del gates,851 907and Events
ChaptSystemr 8 - AdvancednamespaceC# Ty Construction Techniques
.Diagnostics members, 454–456
Part Three - Programming with .NET Assemblies
System.dll assembly, 609,805
Chapter 9 - Understanding .NET Assemblies
System.Double type, 126
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapSystemr 11.Drawing- Type namespace,Reflection, Late673Binding,–675 and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
System.Drawing utility types, 675–679
Chapter 12 - Object Serialization and the .NET Remoting Layer disposal of, 680
ChapterPoint(F)13 - Buildingtype, 675a–Better676 Window (Introducing Windows Forms)
ChapterRectangle(F)14 - A Betterype,Painting677–678Framework (GDI+)
ChapterRegion15 -class,Programming678–679with Windows Forms Controls
ChapterSize(F)16 -types,The System678 .IO Namespace
ChaptSystemr 17 - Data Access with ADO.NET
.Drawing.Color structure, 692
Part Five - Web Applications and XML Web Services
System.Drawing.dll,951
Chapter 18 - ASP.NET Web Pages and Web Controls
System.Drawing.Drawing2D namespace overview, 705–720
Chapter 19 - ASP.NET Web Applications
gradient brushes, 719–720
Chapter 20 - XML Web Services
hatch style brushes, 715–717
Index
pen caps, 711–713
List of Figures
pen objects, 707–711
List of Tables
rendering quality, 706–707 solid brushes, 713–715 textured brushes, 717–718
System.Drawing.Font type, 695
System.Drawing.Graphics object, 675,685
System.Drawing.Image type, 720
System.Drawing.Text,701–703
System.Enum base class, 21,166–168
System.Environment class, 88–89
System.Exception base class, 234–235
System.Exception.StackTrace property, 239
System.Exception.TargetSite property, 238–239
System.GC types, 267–272
finalizable and disposable types, building, 268–269
C# and the .NET Platform, Second Edition forcing garbage collection, 270
by Andrew Troelsen |
ISBN:1590590554 |
generations, interacting with, 270–272 |
|
Apress © 2003 (1200 pages) |
|
members of, 268 |
|
This comprehensive text starts with a brief overview of the
System.Globalization.CultureInfo type, 292
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
System.IO namespace, 805–841
abstract stream class, 818–822
BufferedStreams,822
Table of Contents
FileStreams,820
C# and the .NET Platform, Second Edition
members of, 819
Introduction
MemoryStreams,820–821
Part asynchronousOne - IntroducingIO,C#833and the .NET Platform
ChapterBinaryReaders1 - The Philosophyand BinaryWriters,of .NET 829–831
ChapterDirectoryInfo2 - BuildingandC#FileInfoApplicationstypes, 806–810
Part TwoDirectoryInfo- The C# Programmingtype, 808–811Language
Chapter FileAttributes3 - C# Languageenumeration,Fundamentals809–810
Chapter FileSystemInfo4 - Object-Orientedbase class,Programming807–808with C#
FileInfo class, 814–818
Chapter 5 - Exceptions and Object Lifetime
Open() method, 815–817
Chapter 6 - Interfaces and Collections
OpenRead(), OpenWrite() members, 815–817
Chapter 7 - Callback Interfaces, Delegates, and Events
OpenText(), CreateText(), AppendText() members, 817–818
Chapter 8 - Advanced C# Type Construction Techniques
FileSystemWatcher class, 831–833
Part Three - Programming with .NET Assemblies
members of, 806
Chapter 9 - Understanding .NET Assemblies
overview of, 805–806
Chapter 10 - Processes, AppDomains, Contexts, and Threads static members of Directory class, 812–813
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
StreamWriters and StreamReaders, 822–826
Part Four - Leveraging the .NET Libraries
text files, reading from, 825–826
Chapter 12 - Object Serialization and the .NET Remoting Layer text files, writing to, 824–825
Chapter 13 - Building a Better Window (Introducing Windows Forms)
TextWriter core members, 823–824
Chapter 14 - A Better Painting Framework (GDI+)
StringReader type, 828–829
Chapter 15 - Programming with Windows Forms Controls
StringWriter type, 826–828
Chapter 16 - The System.IO Namespace
subdirectories, creating, 811–812
ChapterSystem17 -.IOData.StreamAccessclass,with ADO818–.NET819
Part WindowsFive - WebFormsApplicationsCar Loggerand XMLapplication,Web Services834–841
Chapter Add18 -NewASP.NETCar logic,Web Pages837–838and Web Controls
Chapter serialization19 - ASP.NETlogic,Web838Applicatio–840 ns
Chapter 20 - XML Web Services
System.MarshalByRefObject
Index
base class, 568
List ofmembers,Figur s 562
List of Tables
System.MulticastDelegate,326,328–329
System.Object
base class, 115–122
default behaviors, overriding, 118–119 Equals(), overriding, 119–120 GetHashCode(), overriding, 120–122 static members of, 122
ToString(), overriding, 119 members,116,563
System.Object.Equals().SeeEquals()
System.Object.Finalize() method, 260–263
System.OverflowException type, 357
System.Random type, 143
System.Reflection namespace
dynamic invocation, 517–520
C# and the .NET Platform, Second Edition late binding, 517–520
by Andrew Troelsen ISBN:1590590554 members of, 511
Apress © 2003 (1200 pages)
MethodBase defined within, 239
This comprehensive text starts with a brief overview of the private assemblies and, 511–515
C# language and then quickly moves to key technical and class members, enumerating, 513–514
architectural issues for .NET developers. method parameters, enumerating, 514–515
referenced assemblies, enumerating types in, 513
shared assemblies, building, 516–517
Table of Contents
C#Systemand the.Resources.NET Platform,namespace,Second Edition733–737
*.resources file
Introduction
binding into .NET assembly, 736–737
Part One - Introducing C# and the .NET Platform
building,735–736
Chapter 1 - The Philosophy of .NET
*.resx file, creating and reading, 733–735
Chapter 2 - Building C# Applications
PartSystemTwo.-RuntimeThe C#.ProgrammingRemoting.dll,554Language
Chapter 3 - C# Language Fundamentals
System.Runtime.Serialization namespace, 549
Chapter 4 - Object-Oriented Programming with C#
System.Runtime.Serialization.Formatters namespace, 544
Chapter 5 - Exceptions and Object Lifetime
System.Runtime.Serialization.Formatters.-Soap.dll,547
Chapter 6 - Interfaces and Collections
ChapSystemr 7.String- Callbackmembers,Interfaces,160 Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
System.SystemException,240–242
Part Three - Programming with .NET Assemblies
System.Text.Encoding object reference, 822
Chapter 9 - Understanding .NET Assemblies
System.Text.StringBuilder,162–164
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapSystemr 11.Threading- Type Reflection,namespaceLate. SeeBinding,alsoandthreadsAttribute,476–-Based480 Programming
Part .FourNET-threadsLeveragiandg thelegacy.NETCOMLibrariesapartments, 479–480
Chapternaming12 -threads,Object Serialization479 and the .NET Remoting Layer
select types, 476–477
Chapt r 13 - Building a Better Window (Introducing Windows Forms)
thread class, 477–478
Chapter 14 - A Better Painting Framework (GDI+)
thread priority level, 480
Chapter 15 - Programming with Windows Forms Controls
thread statistics, 478–479
Chapter 16 - The System.IO Namespace
ChapSystemr 17.Threading- Data Access.Interlockedwith ADOtype,.NET492–493
Part Five - Web Applications and XML Web Services
System.Threading.Monitor type, 491–492
Chapter 18 - ASP.NET Web Pages and Web Controls
System.Threading.Timer type, 495
Chapter 19 - ASP.NET Web Applications
System.Type class, 504–510
Chapter 20 - XML Web Services
members of, 505
Index
obtaining type references, 505–506
List of Figures
project example, 506–510
List of Tables
System.ValueType,20,125 System.Version,513 System.Void type, 330–331
System.Web namespace, 953,1031
System.Web.Caching.Cache class, 1038
System.Web.HttpApplication type members, 1032
System.Web.HttpCookie type, 1048
System.Web.Services namespace, 1064–1065
System.Web.Services.Description namespace, 1084
System.Web.Services.Protocols.SoapHttp-ClientProtocol,1089 System.Web.Services.WebMethod type, 1074 System.Web.Services.WebService base class, 1072–1073
System.Web.StateBag type, 1029
C# and the .NET Platform, Second Edition
System.Web.UI.Control type members, 985–990 |
ISBN:1590590554 |
by Andrew Troelsen |
|
adding and removing controls, 988–990 |
|
Apress © 2003 (1200 pages) |
|
contained controls, 986–988 |
|
This comprehensive text starts with a brief overview of the System.Web.UI.HtmlControls,C# anguage and1014then,1016quickly moves to key technical and
architectural issues for .NET developers.
System.Web.UI.HtmlControls namespace, 941
System.Web.UI.LiteralControl type, 987
Table of Contents
System.Web.UI.MobileControls namespace, 607
C# and the .NET Platform, Second Edition
System.Web.UI.Page base class, 949
Introduction
System.Web.UI.Page.Request property, 971
Part One - Introducing C# and the .NET Platform
ChapSystemr 1.Web- The.UI.PhilosophyWebControlftype.NETmembers, 990–991
Chapter 2 - Building C# Applications
System.Web.UI.WebControl.Button type, 984
Part Two - The C# Programming Language
System.Web.UI.WebControls namespace, 607,984
Chapter 3 - C# Language Fundamentals
System.Web.UI.WebControls.BaseValidator,1006
Chapter 4 - Object-Oriented Programming with C#
ChapSystemr 5.Web- Exceptions.WebControland.TextBoxObject Lifetimetype, 984
Chapter 6 - Interfaces and Collections
System.Windows.Forms namespace, 608,644,693
Chapter 7 - Callback Interfaces, Delegates, and Events
System.Windows.Forms.Application class, 615–621
Chapter 8 - Advanced C# Type Construction Techniques
Application class example, 617–618
Part Three - Programming with .NET Assemblies
ApplicationExit event, 619
Chapter 9 - Understanding .NET Assemblies core properties of, 616–617
Chapter 10 - Processes, AppDomains, Contexts, and Threads events of, 617
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming methods,616
Part Four - Leveraging the .NET Libraries
preprocessing messages with, 619–621
Chapter 12 - Object Serialization and the .NET Remoting Layer
System.Windows.Forms.Button type, 752
Chapter 13 - Building a Better Window (Introducing Windows Forms)
System.Windows.Forms.ContainerControl,637
Chapter 14 - A Better Painting Framework (GDI+)
ChapSystemr 15.Windows- Programming.Forms.Control,with Windows623–624Forms,744Controls
ChaptSystemr 16 - The SystemForms.IO Nassembly,mespace
.Windows. .dll 609
Chapter 17 - Data Access with ADO.NET
System.Windows.Forms.Menu,644
Part Five - Web Applications and XML Web Services
System.Windows.Forms.SaveFileDialog type, 838
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapSystemr 19.Windows- ASP.NET.FormsWeb.ShortcutApplicationsenumeration, 647
ChaptSystemr 20 - XML Web Services
.Xml.dll assembly, 548
Index
System.Xml.Serialization namespace, 1099
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
T |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
tab order |
C# language and then quickly moves to key technical and |
|
architectural issues for .NET developers. |
|
configuring,768
and style sheets, 997
TableTableMappingsof Contentsproperty, 848,925
C# and the .NET Platform, Second Edition
tables
Introdbuildingction HTML, 994–995
Part navigatingOne - IntroducingbetweenC#related,and the880.NET–883Platform
ChapterTables1 -propertyThe Philosophy(DataSets),of .NET874
Chapter 2 - Building C# Applications
TabStop and TabIndex properties, 637
Part Two - The C# Programming Language
tags, XML, 77
Chapter 3 - C# Language Fundamentals
TargetSite property, 238–239
Ch pter 4 - Object-Oriented Programming with C#
ChapterTCP channel5 - Exceptions and Object Lifetime
Chaptdefined,r 6 -558Interfaces and Collections
Chapterleveraging,7 - Callback578–579Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques temporary cookies, defined, 1048
Part Three - Programming with .NET Assemblies
testing,1066–1069
Chapter 9 - Understanding .NET Assemblies compiled .NET assembly, 1068–1069
Chapter 10 - Processes, AppDomains, Contexts, and Threads
WSDL contract, 1068
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
text files
Part Four - Leveraging the .NET Libraries
reading from, 825–826
Chapter 12 - Object Serialization and the .NET Remoting Layer
writing to, 824–825
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Text type, 701
Chapter 14 - A Better Painting Framework (GDI+)
ChapTextBoxeser 15 - Programming with Windows Forms Controls
Chaptercreating16 - scrollable,The Syst mmultiline.IO Namespace(WebForms), 993
Chapterproperties,17 - Data750Access with ADO.NET
Part TextBoxFive - Webcontrol,Applications749–752and XML Web Services
TextBoxBase type members, 749–750
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapTextReaderer 19 - ASP.NET Web Applications
Chaptercore20members,- XML Web825Services
Indextype,822
List of Figures
textual output, formatting, 106–107
List of Tables
textured brushes, 717–718
TextWriter
class,822–824
core members, 823–824
this keyword, 183–184
Thread Local Storage (TLS), 453
threads.See alsoSystem.Threading namespace
.NET threads and legacy COM apartments, 479–480 AppDomain,474–475
concurrency and thread synchronization, 475,487–490 defined,341
multithreaded programming via delegates, 476 naming,479
primary, defined, 452
priority level, setting, 480
C# and the .NET Platform, Second Edition and processes under Win32, 451–453
by Andrew Troelsen |
ISBN:1590590554 |
safety and .NET base class libraries, 494 |
|
Apress © 2003 (1200 pages) |
|
secondary, creating, 481–484 |
|
This comprehensive text starts with a brief overview of the foreground and background threads, 482–483
C# language and then quickly moves to key technical and
VS .NET threads window, 483–484
architectural issues for .NET developers. select types, 476–477
statistics,478–479
thread class, 477–478
Table of Contents
thread set, 458–460
C# and the .NET Platform, Second Edition
thread type, instance level members of, 478
Introduction
thread-volatile operations, 475
Part One - Introducing C# and the .NET Platform
Thread.CurrentContext property, 475
Chapter 1 - The Philosophy of .NET
Thread.GetDomain method, 474
Chapter 2 - Building C# Applications threading example, 484–487
Part Two - The C# Programming Language
clogging up primary thread, 485–486
Chapter 3 - C# Language Fundamentals
Thread.Sleep() method, 486–487
Chapter 4 - Object-Oriented Programming with C#
ThreadStart delegate, 481
Chapter 5 - Exceptions and Object Lifetime worker,452–453
Chapter 6 - Interfaces and Collections
throw keyword, 235–236,249–250
Chapter 7 - Callback Interfaces, Delegates, and Events
time-slice, defined, 453
Chapter 8 - Advanced C# Type Construction Techniques
PartTimeOutThree property,- Programming1046 with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Timer type, Windows Forms, 658–659
Chapter 10 - Processes, AppDomains, Contexts, and Threads
TimerCallbacks,494–496
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Tool bars
Part Four - Leveraging the .NET Libraries
building,660–664
Chapter 12 - Object Serialization and the .NET Remoting Layer
adding images to Tool bar buttons, 663–664
Chapter 13 - Building a Better Window (Introducing Windows Forms)
at design time, 664–666
Chapter 14 - A Better Painting Framework (GDI+)
ToolBar type properties, 660–661
Chapter 15 - Programming with Windows Forms Controls
ToolBarButton type properties, 661
Chapter 16 - The System.IO Namespace
ToolBoxBitmap attribute, 802
Chapter 17 - Data Access with ADO.NET
PartToolTips,Five - 769Web–App770lications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
ToString()
Chapter 19 - ASP.NET Web Applications
method,826
Chapteroverriding,20 - XML119Web Services
Index
tracing
List of Figures
with <trace>, 1052–1053
List of Tables
and debugging ASP.NET pages, 1020
TrackBar Control, 770–772
TranslateTransform() method, 688,691
transparent proxies, 556–557
transport protocol, XML Web, 1063
try/catch blocks, 236–237,247–249
type boundaries,403
CTS members, 22 definition,500 indexers,373–374 metadata,499–504
.NET binary element, 397
documenting defining assembly, 502–503
examples of usage, 399
C# and the .NET Platform, Second Edition referenced assemblies, documenting, 503
by Andrew Troelsen |
ISBN:1590590554 |
string literals, documenting, 503–504 |
|
Apress © 2003 (1200 pages) |
|
typeRef,502 |
|
This comprehensive text starts with a brief overview of the viewing for Car type, 501–502
C# language and then quickly moves to key technical and viewing for EngineState enumeration, 500–501
architectural issues for .NET developers. references,500,505–506
<type> element (WSDL), 1080
visibility,184–186
Table of Contents
C#typeandoftheemployee,.NET Platform,determining,Second223Edition–224
Introduction
typed DataSets
Part defined,One - Introducing927 C# and the .NET Platform
Chapterat design1 - Thetime,Philosophy928–929of .NET
Chapterstructure2 - Buildingof, 929–C#931Applications
Part Two - The C# Programming Language
TypeDef #n tokens, 500
Chapter 3 - C# Language Fundamentals
TypeDefName tokens, 501
Chapter 4 - Object-Oriented Programming with C#
Type.GetCustomAttributes() method, 528
Chapter 5 - Exceptions and Object Lifetime
Chaptertypeof operator,6 - Interfaces490 and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events typeRef,502
Chapter 8 - Advanced C# Type Construction Techniques
TypeRef #n tokens, 500
Part Three - Programming with .NET Assemblies
types
Chapter 9 - Understanding .NET Assemblies
conversions among related class, 387
Chapter 10 - Processes, AppDomains, Contexts, and Threads
interacting with Windows Forms, 609–612
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
pinning via fixed keyword, 365–366
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
U |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
UDDI (Discovery Service Protocol), 1062,1102–1105 |
|
architectural issues for .NET developers.
ufo.netmodule,421–422
Unadvise() method, 324
Table of Contents
unboxing and boxing. Seeboxing and unboxing
C# and the .NET Platform, Second Edition
unchecked keyword, 358–359
Introduction
PartunderflowOne - Introducingand overflow,C# and356,the359.NET Platform
Chapter 1 - The Philosophy of .NET
Unicode encoding, 822
Chapter 2 - Building C# Applications
unit of measure
Part Two - The C# Programming Language
default,688–689
Chapter 3 - C# Language Fundamentals specifying alternative, 689–690
Chapter 4 - Object-Oriented Programming with C#
Unload events, ASP.NET, 978–979
Chapter 5 - Exceptions and Object Lifetime
Chapterunloading6 -AppDomainsInterfaces andprogrammatically,Collections 468
Chapter 7 - Callback Interfaces, Delegates, and Events
Unlock() and Lock() methods, 1037,1043
Chapter 8 - Advanced C# Type Construction Techniques unmanaged resources, 260
Part Three - Programming with .NET Assemblies
unsafe code, 359–366
Chapter 9 - Understanding .NET Assemblies
–> operator, 364
Chapter 10 - Processes, AppDomains, Contexts, and Threads
* and & parameters, 363
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
field access via pointers, 364
Part Four - Leveraging the .NET Libraries
fixed keyword, 365–366
Chapter 12 - Object Serialization and the .NET Remoting Layer stackalloc keyword, 365
Chapter 13 - Building a Better Window (Introducing Windows Forms) swap function, unsafe and safe, 363–364
Chapter 14 - A Better Painting Framework (GDI+) unsafe keyword, 361–363
Chapter 15 - Programming with Windows Forms Controls
untyped DataSets, defined, 927
Chapter 16 - The System.IO Namespace
Up/Down Controls, 774–776
Chapter 17 - Data Access with ADO.NET
PartUpdate()Five - Wmethod,b Applications848 and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
UPDATE SQL statements, 848
Chapter 19 - ASP.NET Web Applications
UpdateGrid() method, 836
Chapter 20 - XML Web Services
updating records
Index
with OleDbCommand, 897–898
List of Figures
with SqlDataAdapter, 910–912
List of Tables
UpDownBase properties, 774 user controls, defined, 789–790 user-defined types (UDTs), 20
User Interfaces in C# (Apress, 2002), 802
User Strings tokens, 503–504
using keyword, 31–32,48,172,265–266
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
V |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
valid overloadable operators, 385 |
|
architectural issues for .NET developers.
validation controls, 1005–1014 custom validation, 1010–1012
Tableprojectof Contentsexample, 1006–1010
C# andpropertiesthe .NETof,Platform,1006 Second Edition
validation summaries, 1012–1014
Introduction
PartvalueOne-based- Introducingand referenceC# and-basedthe .NETtypes,Platform109–114
Chaptercomparison1 - Theof,Philosophy113–114of .NET
Chaptervalue2 types- BuildingcontainingC# Applicationsreference types, 112–113
Part Two - The C# Programming Language
value-based semantics, 119,125,168–169
Chapter 3 - C# Language Fundamentals
value keyword, 194–195
Chapter 4 - Object-Oriented Programming with C#
value semantics, 118
Chapter 5 - Exceptions and Object Lifetime
Chvaluept rtypes6 - andI terfacreferences and Colltypes,ctions128–132
Chapter 7 - Callback Interfaces, Delegates, and Events variable initialization syntax (C#), 104–105
Chapter 8 - Advanced C# Type Construction Techniques variable scope and default assignments, 102–104
Part Three - Programming with .NET Assemblies
VB .NET
Chapter 9 - Understanding .NET Assemblies
C# indexer from, 374–375
Chapter 10 - Processes, AppDomains, Contexts, and Threads
calculator,15
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
client application, 409–411
Part Four - Leveraging the .NET Libraries
snap-in, building, 531–532
Chapter 12 - Object Serialization and the .NET Remoting Layer
special names from, 384–385
Chapter 13 - Building a Better Window (Introducing Windows Forms)
VB .NET and the .NET Platform (Apress, 2002), 412
Chapter 14 - A Better Painting Framework (GDI+)
VBCalculator applications, 14–15
Chapter 15 - Programming with Windows Forms Controls
ChaptVbNetSnapInr 16 - The.dll,System530 .IO Namespace
Chapter 17 - Data Access with ADO.NET
VBScript,944,947–948,950
Part Five - Web Applications and XML Web Services
verbatim strings and escape characters, 161–162
Chapter 18 - ASP.NET Web Pages and Web Controls
versionable and self-describing entities (assemblies), 403
Chapter 19 - ASP.NET Web Applications
Chapterversioning20 - XML Web Services
Indexclass members, 220–222
shared assemblies, 437–438
List of Figures
Listviewof objects,Tables defined, 871
view state, ASP.NET, 1026–1029 custom view state data, 1029 definition and basics, 1026 demonstrating (example), 1027–1029
_VIEWSTATE form field, 951
virtual directories, IIS, 938,1066
virtual keyword, 214,228
virtual members, defined, 22
virtual System.Object.Finalize() method, 260
visibility
traits (CTS members), 22 type and method, 184–186
Visual Basic (VB)
default method names Item, 374
C# and the .NET Platform, Second Edition |
|
runtime module, 25 |
ISBN:1590590554 |
VB 6 IDE, 57 by Andrew Troelsen |
|
Apress © 2003 (1200 pages) |
|
VB 6.0 Object Browser utility, 520 |
|
This comprehensive text starts with a brief overview of the
VB 6.0 programming, 4
C# language and then quickly moves to key technical and
VB 6.0 Set keyword, 374
architectural issues for .NET developers.
volatile keyword, 366
VS .NET
Table of Contents
Add References dialog box, 449
C# and the .NET Platform, Second Edition
Add Web Reference utility, 1095
Introduction
Add Web Reference wizard, 1063
Part addingOne - Introducingcontrols toC#Formsand thewith,.NET747Platform–749
Chapterapplication1 - Thestructure,Philosophy62of .NET
ChapterAssemblyInfo2 - Building.csC#file,Applications527
Part configurationTwo - The C# filesProgrammingand, 428–Lang429uage
Chaptdebuggingr 3 - C#systemLanguageexceptionsFundamentalswith, 253–256
Chapterediting4 -HTMLObjectdocuments-Oriented Programmingwith, 942 with C#
Enterprise edition, 921
Chapter 5 - Exceptions and Object Lifetime
handling custom exceptions with, 255–256
Chapter 6 - Interfaces and Collections
implementing interfaces with, 288–290
Chapter 7 - Callback Interfaces, Delegates, and Events
integrated debugger, 56
Chapter 8 - Advanced C# Type Construction Techniques
overflow checking, 358
Part Three - Programming with .NET Assemblies
project workspace, building, 612–615
Chapter 9 - Understanding .NET Assemblies
Dispose() method, 614–615
Chapter 10 - Processes, AppDomains, Contexts, and Threads
InitializeComponent(),614–615
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming referencing external assemblies via, 67–68
Part Four - Leveraging the .NET Libraries
resource configuration with, 739–742
Chapter 12 - Object Serialization and the .NET Remoting Layer test application, building, 61–70
Chapter 13 - Building a Better Window (Introducing Windows Forms) adding code, 67
Chapter 14 - A Better Painting Framework (GDI+) configuring a C# project, 64–65
Chapter 15 - Programming with Windows Forms Controls inserting new C# type definitions, 68–69
Chapter 16 - The System.IO Namespace
outlining code, 69–70
Chapter properties17 - Data Accesswindow,with66ADO.NET
Part Fivereferencing- W b Applicationsexternal assemblies,nd XML Web67Services–68
Chapter solution18 - ASPexplorer.NET Webwindow,Pages and62–Web64 Controls
Chapterthreads19 -window,ASP.NET483Web Applications
ChapterUDDI20interaction- XML Webwith,Services1103–1105
unsafe compilation, 361
Index
VS .NET 2003, 45
List of Figures
ListVSof.NETTablesIDE
database manipulation tools, 73–74 debugging with, 70–71
default namespace of, 175–176 features of, 71–76
HTML and, 939 Inheritance Picker, 788 integrated help, 74–76 object browser utility, 73
project solution, creating, 60–61 server explorer window, 71–72 start page, 58–59
using,57–61
writing Windows Forms code, 747 XML-related editing tools, 72–73
wizards.Seewizards
XML Web services, building with, 1069–1072
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
W |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
warnings and errors, issuing, 86 |
|
architectural issues for .NET developers.
Watcher class (FileSystemWatcher). SeeFileSystemWatcher class
Web applications. See alsoASP.NET Web applications
Table of Contents
creating manually, 953–958
C# and the .NET Platform, Second Edition
*.aspx file, coding, 954–958
Introduction
<%@Page%> directive, 955
Part One<%Import%>- Introducingdirective,C# and the955.NET–956Platform
Chapter script1 - Theblocks,Philosophy956–957of .NET
Chapter widget2 - Buildingdeclarations,C# Applications957–958
Part creatingTwo - ThewithC#VSProgramming.NET, 961–Lang966uage
Chapter code3 - C#behindLanguagefile, 965Fundamentals–966
Chapter initial4 - Object*.aspx-Orientedfile, 964–Programming965 with C#
defined,936,939
Chapter 5 - Exceptions and Object Lifetime
shutdown,1037
Chapter 6 - Interfaces and Collections
and Web servers, 936–938
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterWeb controls,8 - AdvancedASP.NETC# Type Construction Techniques
Part overviewThree - Programmingof, 982–985with .NET Assemblies
Chapter AutoPostBack9 - Understandingproperty,.NET984Assembli–985es
server-side event handling, 983–984
Chapter 10 - Processes, AppDomains, Contexts, and Threads
System.Web.UI.Control type members, 985–990
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
adding and removing controls, 988–990
Part Four - Leveraging the .NET Libraries
contained controls, 986–988
Chapter 12 - Object Serialization and the .NET Remoting Layer
System.Web.UI.WebControl type members, 990–991
Chapter 13 - Building a Better Window (Introducing Windows Forms)
toolbox,966
Chapter 14 - A Better Painting Framework (GDI+)
validation controls, 1005–1014
Chapter 15 - Programming with Windows Forms Controls custom validation, 1010–1012
Chapter 16 - The System.IO Namespace project example, 1006–1010
Chapter 17 - Data Access with ADO.NET properties of, 1006
Part Five - Web Applications and XML Web Services
validation summaries, 1012–1014
Chapter 18 - ASP.NET Web Pages and Web Controls
WebForm controls, examples of, 991–1005
Chapter 19 - ASP.NET Web Applications
DataGrids.SeeDataGrids, ADO.NET
Chapter 20 - XML Web Services
feature-rich controls, 995–997
Index HTML tables, building, 994–995
List of FiguresListBox controls, 992
List of Tablesradio button types, 992–993 scrollable, multiline TextBoxes, 993
Web Forms, 607–608
Web methods
documenting with Description property, 1073–1074 exposing custom types from, 1096–1097
invoking CalcWS, 1071–1072 overloaded,1092–1093 types, arrays of, 1096–1097 [WebMethod] attribute
ASP.NET runtime and, 1066
Description property, 1073–1074
EnableSession property, 1075–1077
MessageName property, 1074–1075
stateful Web services, building, 1075–1077 WSDL name clashes, 1074–1075
Web pages, ASP.NET. SeeASP.NET Web pages
C# and the .NET Platform, Second Edition
Web servers |
by Andrew Troelsen |
ISBN:1590590554 |
defined,936–937Apress © 2003 (1200 pages) |
|
GDI+ on, 1016–1019
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Web services, XML. SeeXML Web services architectural issues for .NET developers.
Web sites
.NET and non-Microsoft OS, 40–41 Table.NETof Contents-aware programming languages, 10
ASP .NET IDE Web Matrix, 90
C# and the .NET Platform, Second Edition
C# compiler (csc.exe) download, 43
Introduction
DISCO support article, 1063
Part One - Introducing C# and the .NET Platform
Dotnetfx.exe package (Microsoft), 40
Chapter 1 - The Philosophy of .NET
hyperthreading,453
Chapter 2 - Building C# Applications
SharpDevelop IDE, 89
Part Two - The C# Programming Language
WebService behaviors article, 1061
Chapter 3 - C# Language Fundamentals
web.config file, 1050–1057
Chapter 4 - Object-Oriented Programming with C#
configuring session state with, 1077
Chapter 5 - Exceptions and Object Lifetime
custom Web settings with <appSettings>, 1057
Chapter 6 - Interfaces and Collections
elements of, 1052
Chapter 7 - Callback Interfaces, Delegates, and Events
error output with <customErrors>, 1053–1054
Chapter 8 - Advanced C# Type Construction Techniques
storing state with <sessionState>, 1054–1056
Part Three - Programming with .NET Assemblies
tracing with <trace>, 1052–1053
Chapter 9 - Understanding .NET Assemblies
WebControl base class properties, 990–991
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterWebForm11 -controls,Type Reflection,examplesLateof,Binding,991–1005and Attribute-Based Programming
Part DataGridsFour - Leveraging.SeeDataGrids,the .NETADOLibraries.NET
Chaptfeaturer 12 -richObjectcontrols,Serialization995–997and the .NET Remoting Layer
ChapterHTML13 tables,- Buildingbuilding,a Better994Window–995 (Introducing Windows Forms)
ListBox controls, 992
Chapter 14 - A Better Painting Framework (GDI+)
radio button types, 992–993
Chapter 15 - Programming with Windows Forms Controls
scrollable, multiline TextBoxes, 993
Chapter 16 - The System.IO Namespace
Chapter[WebService]17 - Dataattribute,Access1077with–ADO1078.NET
Part Five - Web Applications and XML Web Services
<%@WebService%> directive, 1066
Chapter 18 - ASP.NET Web Pages and Web Controls while and do/while looping constructs, 136–137
Chapter 19 - ASP.NET Web Applications
widget declarations, ASP.NET, 957–958
Chapter 20 - XML Web Services
Indexwildcard character (*), 50
List of Figures
Win32
List of Tables
threads and processes under, 451–453 WIN32API,260
wincv.exe desktop application, 39
Windows DNA (Distributed iNternet Architecture) programming, 6
Windows file header, 397–398
Windows Forms, 607–669
applications, building extendible, 532–534 building menus with, 644–646
Menu type members, 645
Menu$MenuItemCollection type, 645–646
Car Logger application, 834–841 Add New Car logic, 837–838 serialization logic, 838–840
client, building (XML Web services), 1097 Component class, 622
ContainerControl class, 637
C# and the .NET Platform, Second Edition |
|
||
Control class, 623–627,633–636 |
ISBN:1590590554 |
||
by Andrew |
Troelsen |
|
|
Control class example, 634–635 |
|
||
Apress © 2003 (1200 pages) |
|
||
control methods, 634 |
|
This comprehensive text starts with a brief overview of the
Form styles, setting, 624–626
C# language and then quickly moves to key technical and members of, 624
architectural issues for .NET developers. painting basics, 635–636
properties of, 623,633
Control events, 627–631
Table of Contents
control class example, 627–628
C# and the .NET Platform, Second Edition
Mouse events, responding to, 628–631
Introduction
MouseEventArgs type properties, 629
Part One - Introducing C# and the .NET Platform
controls,683–684
Chapter 1 - The Philosophy of .NET example,914–916
Chapter 2 - Building C# Applications
Form class, 637–640
Part Two - The C# Programming Language
example,639–640
Chapter 3 - C# Language Fundamentals key methods of, 638–639
Chapter 4 - Object-Oriented Programming with C# properties of, 638
Chapter 5 - Exceptions and Object Lifetime select events of, 639
Chapter 6 - Intevents,rfaces handlingCollections
Form level with VS .NET, 643–644
ChapterForms,7 -anatomyCallback of,Interfaces,621–622Delegates, and Events
ChapterGUI8namespaces,- Advanc d C#607Type–608Construction Techniques
Part KeyboardThree - Programmingevents, respondingwith .NETto,Assemblies631–633
ChapterMDI9applications,- Understandingbuilding,.NET666Assemblies–669
Chapter child10 - Form,Processes,668AppDomains, Contexts, and Threads
child windows, 668–669
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
parent Form, 666–667
Part Four - Leveraging the .NET Libraries
menus
Chapter 12 - Object Serialization and the .NET Remoting Layer
building with VS .NET, 654–655
Chapter 13 - Building a Better Window (Introducing Windows Forms)
menu system, building, 646–649
Chapter 14 - A Better Painting Framework (GDI+)
MenuItem type properties, 651–653
Chapter 15 - Programming with Windows Forms Controls
pop-up, creating, 649–651
Chapter 16 - The System.IO Namespace
ScrollableControl class, 636–637
Chapter 17 - Data Access with ADO.NET
Status bars, 655–660
Part Five - Web Applications and XML Web Services
building,656–657
Chapter 18 - ASP.NET Web Pages and Web Controls menu selection prompts, 659–660
Chapter 19 - ASP.NET Web Applications select properties of, 655
Chapter 20 - XML Web Services
StatusBarPanel type properties, 656
Index Timer type, 658–659
List of Figures
System.Windows.Forms namespace overview, 608
List ofSystemTables.Windows.Forms.Application class, 615–621
Application class example, 617–618
ApplicationExit event, 619
core properties of, 616–617 events of, 617 methods,616
preprocessing messages with, 619–621 Tool bars, building, 660–664
adding images to Tool bar buttons, 663–664 ToolBar type properties, 660–661 ToolBarButton type properties, 661
Tool bars, building at design time, 664–666 types, interacting with, 609–612
Main window, building, 610–612 project work space, preparing, 609
VS .NET project workspace, building, 612–615
Dispose() method, 614–615
C# and the .NET Platform, Second Edition |
|
InitializeComponent(),614–615 |
ISBN:1590590554 |
by Andrew Troelsen |
|
Windows Form type life-cycle, 640–643 |
|
Apress © 2003 (1200 pages) |
|
Form life time events, 640–641 |
|
This comprehensive text starts with a brief overview of the
Form lifetime example, 642–643
C# language and then quickly moves to key technical and
Windows Forms Controls, 743–803
architectural issues for .NET developers. adding to Forms, 744–747
adding to Forms with VS .NET, 747–749
Tableanchoringof C ntentsbehavior, configuring, 779–780
C# andanimation,the .NET796Platform, Second Edition
assigning ToolTips to, 769–770
Introduction
Button type, 752–755
Part One - Introducing C# and the .NET Platform
content position, configuring, 753
Chapter 1 - The Philosophy of .NET
example,754–755
Chapter 2 - Building C# Applications
CarControl
Part Two - The C# Programming Language
custom events, defining, 794
Chapter 3 - C# Language Fundamentals
custom properties, defining, 794–796
Chapter 4 - Object-Oriented Programming with C# Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections testing,797–798
Chapter 7 - Callback Interfaces, Delegates, and Events
CheckBoxes,755–756
Chapter 8 - Advanced C# Type Construction Techniques
custom dialog boxes, building, 781–787
Part Three - Programming with .NET Assemblies
application example, 782–785
Chapter 9 - Understanding .NET Assemblies
DialogResult property, 785
Chapter 10 - Processes, AppDomains, Contexts, and Threads
grabbing data from, 785–787
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming custom UserControl, building, 790–791
Part customFour - LeveragingWindows Formsthe .NETControls,Lib ariesbuilding, 789–790
ChapterDateTime12 - Objecttype,Serialization766–767 and the .NET Remoting Layer
Chaptdefaultr 13 -inputBuildingButton,a Better767 Window (Introducing Windows Forms)
Chaptdesignr 14 -timeA BetterGUI,Paintingbuilding,Framework792 (GDI+)
Chapterdocking15 - behavior,Programmingconfiguring,with Windows780–781Forms Controls
DomainUpDown and NumericUpDown Controls, 774–776
Chapter 16 - The System.IO Namespace
ErrorProvider type, 776–778
Chapter 17 - Data Access with ADO.NET
Form inheritance, 787–789
Part Five - Web Applications and XML Web Services
hierarchy of, 743–744
Chapter 18 - ASP.NET Web Pages and Web Controls
images, creating, 791
Chapter 19 - ASP.NET Web Applications
ListBoxes and ComboBoxes, 761–763
Chapter 20 - XML Web Services
MonthCalendar Control, 763–766
Index
Panel Controls, 773
List of Figures
pet name rendering, 796
List of Tables
RadioButtons and GroupBoxes, 756–760
CheckedListBox Control, 758–760 example,756–758
System.ComponentModel namespace, 798–799 tab order, configuring, 768
TextBox control, 749–752
TrackBar Control, 770–772
Up/Down Controls, 774–776
Windows OS 2000 and XP Professional, 937
Windows service and hosting remote objects, 597–598
wire protocols, 1086–1089
HTTP GET and HTTP POST messages, 1087
SOAP messages, 1088–1089
wizards
Add Member, 228
Add Web Reference, 1063
C# and the .NET Platform, Second Edition
Data Adapter Configuration, 922–926
by Andrew Troelsen ISBN:1590590554
Data Adapters and design time connections, 926–927
Apress © 2003 (1200 pages)
Property Builder, 1000
This comprehensive text starts with a brief overview of the
Solutions Explorer, 919–921
C# language and then quickly moves to key technical and
SQL connection, 921–922
architectural issues for .NET developers.
Tab Order, 768
WKO (Well Known Object) types
Tableactivationof Contentsmode of, 576–577
C# andCAO/WKOthe .NET-singletonPlatform, Secondobjects,Edition589–595
characteristics of, 587
Introduction
configuration of, 565
Part One - Introducing C# and the .NET Platform
defined,564
Chapter 1 - The Philosophy of .NET
ChapterWM LBUTTONDOWN2 - Building C# Applicmessage,tions619–621
Part Two - The C# Programming Language
WNDCLASSEX structure, 624
Chapter 3 - C# Language Fundamentals
worker threads, 452–453
Chapter 4 - Object-Oriented Programming with C#
write-only and read-only properties, 197–198
Chapter 5 - Exceptions and Object Lifetime ChaptWriteTo()r 6 method,- Interfaces821and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
WriteXml() method, 883
Chapter 8 - Advanced C# Type Construction Techniques
WriteXmlSchema() method, 885
Part Three - Programming with .NET Assemblies
Writing Add-Ins for VS .NET (Apress, 2002), 534
Chapter 9 - Understanding .NET Assemblies
ChapterWSDL10(Web- ProcessServices,DescriptionAppDomains,Language)Contexts, and Threads
Chaptercontract,11 - Type1068Reflection, Late Binding, and Attribute-Based Programming
Part defined,Four - Leveraging1063 the .NET Libraries
Chapterdocument12 - Objectformat,Serialization1079–1082and the .NET Remoting Layer
<binding> element, 1082
Chapter 13 - Building a Better Window (Introducing Windows Forms)
<message> element, 1081
Chapter 14 - A Better Painting Framework (GDI+)
<portType> element, 1081
Chapter 15 - Programming with Windows Forms Controls
<service> element, 1082
Chapter 16 - The System.IO Namespace
<type> element, 1080
Chapter 17 - Data Access with ADO.NET
fundamentals of, 1078–1079
Part Five - Web Applications and XML Web Services
name clashes, 1074–1075
Chapter 18 - ASP.NET Web Pages and Web Controls transforming into C# code, 1089–1091
Chapter 19 - ASP.NET Web Applications proxy code, 1089–1091
Chapter 20 - XML Web Services
wrapping proxy type in .NET namespace, 1091
Index
wsdl.exe command line utility, 1079,1084–1086
List of Figures
List of Tables
Index |
C# and the .NET Platform, Second Edition |
|
|
|
|
|
by Andrew Troelsen |
ISBN:1590590554 |
X |
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the |
||
|
C# language and then quickly moves to key technical and |
|
XML (Extension Markup Language) |
|
architectural issues for .NET developers. configuration files, 426–429
data representation
configuring in DataColumns, 857–858
Table of Contents
passing information with, 1060
C# and the .NET Platform, Second Edition
documenting source code via, 76–79
Introduction
files, viewing generated, 79–81
Part One - Introducing C# and the .NET Platform
format characters, 80
Chapter 1 - The Philosophy of .NET formatter (serialization), 548
Chapter 2 - Building C# Applications
XML-based DataSets, 883–885
Part Two - The C# Programming Language
XML-related editing tools, 72–73
Chapter 3 - C# Language Fundamentals
XML Web services, 1059–1105
Chapter 4 - Object-Oriented Programming with C#
arrays of Web method types, 1096–1097
Chapter 5 - Exceptions and Object Lifetime building manually, 1065–1066
Chapter 6 - Interfaces and Collections building with VS .NET, 1069–1072
Chapter 7 - Callback Interfaces, Delegates, and Events adding functionality, 1071
Chapter 8 - Advanced C# Type Construction Techniques
CalcWS Web methods, 1071–1072
Part Three - Programming with .NET Assemblies
code behind file (*.asmx.cs), 1070–1071
Chapter 9 - Understanding .NET Assemblies
CarSalesInfoWS project, 1100–1102
Chapter 10 - Processes, AppDomains, Contexts, and Threads
custom types
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
consuming,1099–1100
Part Fourexposing,- Leveraging1098–the1099.NET Libraries
Chaptdescriptionr 12 - Objectservice,Serialization1063 and the .NET Remoting Layer Chapterdiscovery13 - Buildingservice,a 1062Better–1063Window (Introducing Windows Forms) Chaptgeneratingr 14 - A BetterproxyPaintingwith VS Framework.NET, 1095(GDI+) Chapterhard15-coded- Programmingproxy logic,with1094Windows Forms Controls
HelloWS WSDL document, 1082–1084
Chapter 16 - The System.IO Namespace
invocations
Chapter 17 - Data Access with ADO.NET
asynchronous,1093–1094
Part Five - Web Applications and XML Web Services
synchronous,1092–1093
Chapter 18 - ASP.NET Web Pages and Web Controls
namespaces,1064
Chapter 19 - ASP.NET Web Applications
overview of, 1059–1061
Chapter 20 - XML Web Services
System.Web.Services namespace, 1064–1065
Index
System.Web.Services.WebService base class, 1072–1073
List of Figures testing,1066–1069
List of Tables
compiled .NET assembly, viewing, 1068–1069 WSDL contract, viewing, 1068
transport protocol, 1063
UDDI (Discovery Service Protocol), 1102–1105 [WebMethod] attribute, 1073–1077
Description property, 1073–1074 EnableSession property, 1075–1077 MessageName property, 1074–1075 stateful Web services, building, 1075–1077 WSDL name clashes, 1074–1075
[WebService] attribute, 1077–1078 Windows Forms client, building, 1097 wire protocols, 1086–1089
HTTP GET and HTTP POST messages, 1087
SOAP messages, 1088–1089
WSDL document format, 1079–1082
<binding> element, 1082
C# and the .NET Platform, Second Edition
<message> element, 1081
by Andrew Troelsen |
ISBN:1590590554 |
<portType> element, 1081 |
|
Apress © 2003 (1200 pages)
<service> element, 1082
This comprehensive text starts with a brief overview of the
<type> element, 1080
C# language and then quickly moves to key technical and
WSDL fundamentals, 1078–1079
architectural issues for .NET developers.
WSDL, transforming into C# code, 1089–1091 proxy code, 1089–1091
wrapping proxy type in .NET namespace, 1091
Table of Contents
wsdl.exe command line utility, 1084–1086
C# and the .NET Platform, Second Edition
XMLSerializer data type, 1098–1099
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
List of FiguresC# and the .NET Platform, Second Edition
by Andrew Troelsen ISBN:1590590554
Apress © 2003 (1200 pages)
Chapter 1: The Philosophy of .NET
This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 1-1: The CLR, CTS, CLS base class library relationship
Figure 1-2: All .NET-aware compilers emit IL instructions and metadata.
Table of Contents
Figure 1-3: mscoree.dll in action
C# and the .NET Platform, Second Edition
Introduction
Figure 1-4: The base class libraries
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Figure 1-5: Your new best friend, ildasm.exe
Chapter 2 - Building C# Applications
Part TwoFigure- The1-6:C#ViewingProgrammingthe underlyingLanguageCIL
Chapter 3 - C# Language Fundamentals
Figure 1-7: Dumping namespace information to file
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Figure 1-8: Dumping CIL to file
Chapter 6 - Interfaces and Collections
Figure 1-9: Viewing type metadata via ildasm.exe
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Figure 1-10: Double click here to view the assembly manifest.
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Figure 1-11: Viewing types using the ClassViewer Web application
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 1-12: Working with wincv.exe
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
ChapterChapter12 - Object2: BuildingSer alization C#and theApplications.NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A BetterEstablishingPainting Framework (GDI+)
Figure 2-1: the path to csc.exe
Chapter 15 - Programming with Windows Forms Controls
Figure 2-2: The TestApp in action
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Figure 2-3: Your first Windows Forms application
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pagdefaults and Web Controls
Figure 2-4: Behold, the response file
Chapter 19 - ASP.NET Web Applications
Figure 2-5: Documenting the bug
Chapter 20 - XML Web Services
Index
Figure 2-6: The entire bug report
List of Figures
List ofFigureTabl s2-7: Debugging at the command line
Figure 2-8: The Projects tab of the VS .NET Start Page
Figure 2-9: The My Profile tab of the VS .NET Start Page
Figure 2-10: The New Project dialog box
Figure 2-11: The Solution Explorer
Figure 2-12: Class View
Figure 2-13: Type sorting options
Figure 2-14: Configuring your C# project starts here.
Figure 2-15: File names may be changed using the Properties window.
Figure 2-16: Class names can also be changed using the Properties window.
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 2-17: The Add References dialog box |
|
Apress © 2003 (1200 pages)
Figure 2-18: Collapsing the SayHi() method
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Figure 2-19: Setting breakpoints
architectural issues for .NET developers.
Figure 2-20: The Server Explorer window
Table of Contents
Figure 2-21: The integrated XML editor
C# and the .NET Platform, Second Edition
IntroductionFigure 2-22: The integrated Object Browser
Part One - Introducing C# and the .NET Platform
Figure 2-23: Integrated database editors
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Figure 2-24: Visual Studio .NET Integrated Help
Part Two - The C# Programming Language
ChapterFigure3 -2C#-25:LanguageRemember,FundamentalsF1 is your friend.
Chapter 4 - Object-Oriented Programming with C#
Figure 2-26: Again, F1 is your friend.
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Figure 2-27: Specifying the XML documentation file via VS .NET
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterFigure8 -2Advanced-28: XmlCarDoc# Type.xmlConstruction Techniques
Part Three - Programming with .NET Assemblies
Figure 2-29: Configuration of your HTML-based documentation
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 2-30: The generated XmlCarDoc online documentation
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourFigure- Leveraging2-31: Regionsthe .NETat workLibraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 2-32: Configuring debug or release builds
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Figure 2-33: Setting project-wide symbols
Chapter 15 - Programming with Windows Forms Controls
ChapterFigure16 -2The-34:SystemViewing.IOlineNamespacenumbers within VS .NET
Chapter 17 - Data Access with ADO.NET
Figure 2-35: Obtaining various environment variables
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapterChapter19 - ASP3:.NETC#WebLanguageApplications Fundamentals
Chapter 20 - XML Web Services
IndexFigure 3-1: Supplying and processing command line arguments
List of Figures
Figure 3-2: Setting command arguments via VS .NET
List of Tables
Figure 3-3: Simple constructor logic
Figure 3-4: Viewing default values for member data
Figure 3-5: Basic IO using System.Console
Figure 3-6: Simple format characters
Figure 3-7: String format flags in action
Figure 3-8: Assignment of value types results in a verbatim copy of each field.
Figure 3-9: Assignment of reference types copies the reference.
Figure 3-10: The internal references point to the same object!
Figure 3-11: Default implementation of select System.Object members
Figure 3-12: Overridden System.Object members in action
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 3-13: The hierarchy of System types
Apress © 2003 (1200 pages)
Figure 3-14: ThisRandomc prehensiveteenager chattertext starts with a brief overview of the
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 3-15: Static data is shared among like objects.
Figure 3-16: Passing reference types by value locks the reference in place.
Table of Contents
Figure 3-17: Passing reference types by reference allows the reference to be redirected.
C# and the .NET Platform, Second Edition
Introduction
Figure 3-18: A multidimensional array
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Figure 3-19: Jagged arrays
Chapter 2 - Building C# Applications
Figure 3-20: Fun with System.Array
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Figure 3-21: Configuring the default namespace
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 4: Object-Oriented Programming with C#
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 4-1: A simple class definition
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Figure 4-2: Internal and public types
Chapter 9 - Understanding .NET Assemblies
ChapterFigure10 -4Processes,-3: The "isAppDomai-a" relationship, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 4-4: The "has-a" relationship
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 4-5: Classical polymorphism
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterFigure14 -4A-6:BetterAd hocPaintingpolymorphismFramework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 4-7: The value of "value" when setting EmpID to 81
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Figure 4-8: Properties map to hidden get_ and set_ methods.
Part Five - Web Applications and XML Web Services
ChapterFigure18 -4ASP-9: .TheNETemployeeWeb Pag shierarchyand Web Controls
Chapter 19 - ASP.NET Web Applications
Figure 4-10: The extended employee hierarchy
Chapter 20 - XML Web Services
IndexFigure 4-11: The contained Radio in action
List of Figures
List ofFigureTabl s4-12: The current employee hierarchy does not honor polymorphism.
Figure 4-13: A better bonus system (thanks to polymorphism)
Figure 4-14: Our current shapes hierarchy
Figure 4-15: Virtual methods do not have to be overridden.
Figure 4-16: Better! Abstract members must be overridden.
Figure 4-17: Versioning the Draw() method
Figure 4-18: Adding a new class via VS .NET
Figure 4-19: The Add Class Wizard
Figure 4-20: Specifying the base class
Figure 4-21: Implementing (not inheriting) select interfaces
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 4-22: The Add Member Wizard |
|
Apress © 2003 (1200 pages)
Chapter 5: ThisExceptionsom rehe siveandtext startsObjectwith a brLifetimeef overvi w of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 5-1: Dealing with the error using structured exception handling
Figure 5-2: Obtaining detailed error information
Table of Contents
C# and the .NET Platform, Second Edition
Figure 5-3: Identifying the exceptions thrown from a given method
Introduction
Part OneFigure- Introducing5-4: ApplicationandC# thesystem.NET Platformexceptions
Chapter 1 - The Philosophy of .NET
Figure 5-5: You have just entered no-man's land.
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Figure 5-6: Preparing to enable VS .NET exception handling
Chapter 3 - C# Language Fundamentals
ChapterFigure4 -5Object-7: The-OrientedCLR exceptionProgrammingset with C#
Chapter 5 - Exceptions and Object Lifetime
Figure 5-8: Specifying VS .NET exception support for a given exception
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 5-9: Enabling your custom application exceptions via VS .NET
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeFigure- Programming5-10: Handlingwithyour.NETcustomAssembliesapplication exceptions via VS .NET
Chapter 9 - Understanding .NET Assemblies
Figure 5-11: Reference types are allocated on the managed heap.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 5-12: Finalizers are called automatically upon application shutdown.
Part Four - Leveraging the .NET Libraries
ChapterFigure12 -5Object-13: TheS rializationinterplay ofandfinalizationthe .NET Remotingand disposalLayer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 5-14: Influencing an object's current generation
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
ChapterChapter16 - The6:SystemInterfaces.IO Namespandce Collections
Chapter 17 - Data Access with ADO.NET
Part FiveFigure- Web6-1:ApplicationsThe updatedandshapesXML WebhierarchyServices
Chapter 18 - ASP.NET Web Pages and Web Controls
Figure 6-2: Dynamically determining implemented interfaces
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Figure 6-3: Interfaces as parameters
Index
List ofFigureFigures6-4: A versioned interface hierarchy
List of Tables
Figure 6-5: Implementing interfaces via VS .NET
Figure 6-6: Specifying interfaces for new types
Figure 6-7: MemberwiseClone() copies references, not values.
Figure 6-8: Now you have a true deep copy.
Figure 6-9: Comparing automobiles based on car ID
Figure 6-10: Sorting automobiles by pet name
Figure 6-11: The System.Collections interface hierarchy
Figure 6-12: Fun with System.Collections.ArrayList
Figure 6-13: System.Collections.Queue at work
Figure 6-14: System.Collections.Stack type at work
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Figure 6-15: The updated Cars container |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief ov |
rview of the |
Chapter 7: Callback Interfaces, Delegates, and Events
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Figure 7-1: An interface-based event protocol
Figure 7-2: The C# "delegate" keyword represents a sealed type deriving from
Table of Contents
System.MulticastDelegate.
C# and the .NET Platform, Second Edition
Introduction
Figure 7-3: Dynamically "pointing to" various methods
Part One - Introducing C# and the .NET Platform
ChapterFigure1 -7The-4: Remember!Philosophy ofC#.NETdelegate types alias System.MulticastDelegate
Chapter 2 - Building C# Applications
Figure 7-5: Passing the buck
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Figure 7-6: Passing the buck yet again
Chapter 4 - Object-Oriented Programming with C#
ChapterFigure5 -7Exceptions-7: Asynchronousand ObjectinvocaLifetionsme increase program responsiveness.
Chapter 6 - Interfaces and Collections
Figure 7-8: Asynchronous invocations via callbacks
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Figure 7-9: Hooking into the engine events
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 8: Advanced C# Type Construction Techniques
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 8-1: Enabling VS .NET overflow checking
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 8-2: Enabling VS .NET unsafe compilation
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterFigure14 -8A-3:BetterInternalP intingCIL representationFramework (GDI+)of overloaded operators
Chapter 15 - Programming with Windows Forms Controls
Figure 8-4: CIL representation of user-defined conversion routines
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Chapter 9: Understanding .NET Assemblies
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Figure 9-1: Assembly Win32 header file information
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Figure 9-2: A single file assembly
Index
List of Figures
Figure 9-3: A multifile assembly
List of Tables
Figure 9-4: The physical view of a .NET assembly
Figure 9-5: The logical view of a .NET assembly
Figure 9-6: Creating a C# code library (e.g., a managed *.dll)
Figure 9-7: Referencing external .NET assemblies begins here.
Figure 9-8: Local copies of (non-shared) assemblies are placed in your Debug folder.
Figure 9-9: Selecting a VB .NET Windows Forms Application
Figure 9-10: A painfully simple GUI
Figure 9-11: Cross-language inheritance in action
Figure 9-12: An MC++ project workspace
Figure 9-13: Your car library as seen via ildasm.exe
C# and the .NET Platform, Second Edition
Figure 9-14: byTypeAndrmetadataw Troelsenfor the types within carlibrary.dllISBN:1590590554
Apress © 2003 (1200 pages)
Figure 9-15: Your multifile assembly
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Figure 9-16: The ufo.netmodule
architectural issues for .NET developers.
Figure 9-17: A single module of the multifile assembly
Table of Contents
Figure 9-18: *.netmodules are loaded on demand.
C# and the .NET Platform, Second Edition
IntroductionFigure 9-19: Relocating CarLibrary.dll into a specific subdirectory
Part One - Introducing C# and the .NET Platform
Figure 9-20: Working with the app.config file
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Figure 9-21: Preventing automatic re-copying of private assemblies
Part Two - The C# Programming Language
ChapterFigure3 -9C#-22:LanguageThe GlobalFundamAssemblyntals Cache
Chapter 4 - Object-Oriented Programming with C#
Figure 9-23: Using sn.exe to generate the public/private key pair file
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Figure 9-24: A strongly named assembly documents the public key in the manifest.
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterFigure8 -9Advanced-25: Our stronglyC# Typenamed,ConstructionsharedTechniquesassembly (version 1.0.0.0)
Part Three - Programming with .NET Assemblies
Figure 9-26: Freezing the current version of SharedAssembly.dll
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 9-27: Side-by-side execution
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourFigure- Leveraging9-28: Thethidden.NETGACLibrariessubdirectory
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 9-29: Inside the hidden \SharedAssembly subdirectory
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Figure 9-30: Behold! The GAC's internal copy of sharedassembly.dll
Chapter 15 - Programming with Windows Forms Controls
ChapterFigure16 -9The-31:SystemOur publisher.IO Namespacepolicy assembly
Chapter 17 - Data Access with ADO.NET
Figure 9-32: The .NET administration utility
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Figure 9-33: Declaratively building a *.config file
Chapter 19 - ASP.NET Web Applications
ChapterFigure20 -9XML-34:WebSuggestingrvicesCarLibrary.dll to VS .NET developers
Index
ListChapterof Figur s 10: Processes, AppDomains, Contexts, and Threads
List of Tables
Figure 10-1: The Windows Task Manager
Figure 10-2: The Win32 process / thread relationship
Figure 10-3: Enumerating running processes
Figure 10-4: Enumerating the threads within a running process
Figure 10-5: Enumerating the loaded modules within a running process
Figure 10-6: Enumerating assemblies within a given app domain (within a given process)
Figure 10-7: A single process with two application domains
Figure 10-8: The AppDomainManipulator.exe process under the hood
Figure 10-9: Processes, application domains, and context boundaries
Figure 10-10: Investigating an object's context
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 10-11: Your first multithreaded application |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts |
ith a brief overview of the |
Figure 10-12: The VS .NET Threads window
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 10-13: Two threads each performing a unit of work
Figure 10-14: Possible output of the MultiThreadSharedData application
Table of Contents
Figure 10-15: Another possible output of the MultiThreadSharedData application
C# and the .NET Platform, Second Edition
Introduction
Figure 10-16: Consistent output of the MultiThreadSharedData application
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Figure 10-17: Many (but not all) .NET types are already thread-safe .
Chapter 2 - Building C# Applications
Figure 10-18: The (very useful) console-based clock application
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
ChapterChapter4 - Object11:-TypeOrient dReflection,Programming withLateC# Binding, and Attribute-Based
Chapter 5 - Exceptions and Object Lifetime
Programming
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 11-1: Viewing an assembly's metadata
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeFigure- Programming11-2: Reflectingwithon.NETFooAssemblies
Chapter 9 - Understanding .NET Assemblies
Figure 11-3: Reflecting on a private assembly
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 11-4: Late bound method invocation
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 11-5: Attributes in action
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 11-6: Attributes seen via ildasm.exe
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 11-7: Metadata value
Chapter 16 - The System.IO Namespace
ChapterFigure17 -11Data-8: AccessInput forwitha snapADO-.inNETmodule
Part Five - Web Applications and XML Web Services
Figure 11-9: Snapping in external assemblies
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
ChapterChapter20 - XML12:WebObjectServi es Serialization and the .NET Remoting Layer
Index
List ofFigureFigures12-1: A simple object graph
List of Tables
Figure 12-2: The Serializable and NonSerialized attributes
Figure 12-3: JamesBondCar serialized using a BinaryFormatter
Figure 12-4: JamesBondCar serialized using a SoapFormatter
Figure 12-5: The serialization process
Figure 12-6: Custom serialization
Figure 12-7: A high-level view of the default .NET Remoting architecture
Figure 12-8: The server's output
Figure 12-9: The client's output
Figure 12-10: Enumerating client-side channels
Figure 12-11: Server-side statistics
C# and the .NET Platform, Second Edition
Figure 12-12:bySingletonAndrew TroelsenWKOs are shared among remoteISBN:1590590554clients.
Apress © 2003 (1200 pages)
Figure 12-13: Single call WKOs maintain a one-to-one relationship with their remote clients.
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Figure 12-14: The default lease information for CarProvider architectural issues for .NET developers.
Figure 12-15: Altering lease timing via a server-side *.config file
Table of Contents
Figure 12-16: Creating a new Windows Service project workspace
C# and the .NET Platform, Second Edition
IntroductionFigure 12-17: Including an installer for the custom Windows Service
Part One - Introducing C# and the .NET Platform
Figure 12-18: The Windows Services Applet
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
PartChapterTwo - The13:C# ProgrammBuildingg Languagea Better Window (Introducing Windows Forms)
Chapter 3 - C# Language Fundamentals
ChapterFigure4 -13Object-1: The-OrientedminimalProgrammingset of assemblywith C#references
Chapter 5 - Exceptions and Object Lifetime
Figure 13-2: A simple main window a la Windows Forms
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 13-3: Specifying /t—winexe within VS .NET
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeFigure- Programming13-4: The Windowswith .NETFormsAs embliesproject workspace
Chapter 9 - Understanding .NET Assemblies
Figure 13-5: The Form Designer
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 13-6: The Properties window provides design time editing support.
Part Four - Leveraging the .NET Libraries
ChapterFigure12 -13Object-7: ReadingSerializationattributesand thevia.theNETApplicationRemoting Latypeer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 13-8: The derivation of a custom Form
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 13-9: ControlStyles.ResizeRedraw = false
Chapter 16 - The System.IO Namespace
ChapterFigure17 -13Data-10:AccessControlStyleswith ADO.ResizeRedraw.NET = true
Part Five - Web Applications and XML Web Services
Figure 13-11: Intercepting key presses
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Figure 13-12: Scroll Form GUI
Chapter 20 - XML Web Services
IndexFigure 13-13: Form events
List of Figures
Figure 13-14: Form events
List of Tables
Figure 13-15: Menu-centric types of Windows Forms
Figure 13-16: A more elaborate main menu
Figure 13-17: Check-marking a menu item
Figure 13-18: The integrated menu editor of VS .NET
Figure 13-19: Handing menu-centric events using VS .NET
Figure 13-20: A custom status bar
Figure 13-21: A custom tool bar
Figure 13-22: Toolbars a la VS .NET
Figure 13-23: Assigning an ImageList via VS .NET
Figure 13-24: Assigning images to ToolBar buttons
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 13-25: The parent window's menu system
Apress © 2003 (1200 pages)
Figure 13-26:ThisSpawningcomprehensivechild windowstext starts with a brief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Chapter 14: A Better Painting Framework (GDI+)
Table Figureof Contents14-1: A simple GDI+ application
C# and the .NET Platform, Second Edition
Figure 14-2: The default coordinate system of GDI+
Introduction
Part One - Introducing C# and the .NET Platform
Figure 14-3: Rendering via pixel units
Chapter 1 - The Philosophy of .NET
ChapterFigure2 -14Building-4: RenderingC# Applicationsvia inch units
Part Two - The C# Programming Language
Figure 14-5: The result of applying page offsets
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Figure 14-6: Altering coordinate and measurement modes
Chapter 5 - Exceptions and Object Lifetime
ChapterFigure6 -14Interfaces-7: The stockand Collections.NET color dialog
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 14-8: Gathering statistics of the Verdana font family
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Figure 14-9: Font metrics
Chapter 9 - Understanding .NET Assemblies
ChapterFigure10 -14Processes,-10: MenuAppDlayoutmains,of theContexts,FontAppandprojectThreads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 14-11: The FontApp application in action
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 14-12: The stock .NET Font dialog
Chapter 13 - Building a Better Window (Introducing Windows Forms) ChapterFigure14 -14A -Better13: WorkingPaintingwithFramPenworktypes(GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 14-14: Working with pen caps
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Figure 14-15: Working with Brush types
Part Five - Web Applications and XML Web Services
ChapterFigure18 -14ASP-16:.NETTheWebhatchPagesstylesand Web Controls
Chapter 19 - ASP.NET Web Applications
Figure 14-17: Bitmaps as brushes
Chapter 20 - XML Web Services
IndexFigure 14-18: Gradient brushes at work
List of Figures
List ofFigureTabl s14-19: Rendering images
Figure 14-20: The amazing happy-dude game
Figure 14-21: You have nerves of steel...
Figure 14-22: Hit-testing polygons
Figure 14-23: An application with three external resources
Figure 14-24: The ResX application
Figure 14-25: Viewing the *.resx file a la VS .NET
Figure 14-26: The binary *.resources file
Figure 14-27: The embedded resources
Figure 14-28: Reading (and using) embedded resources
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 14-29: The underlying *.resx file for MainForm.cs |
|
Apress © 2003 (1200 pages)
Figure 14-30: Under VS .NET, *.resx files are automatically embedded into your assembly.
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Figure 14-31: GUI of the ResLoader application architectural issues for .NET developers.
Figure 14-32: Loading resources with the ResourceManager type
Table of Contents
C#Chapterand the .NET15:Platform,ProgrammingSecond Edition with Windows Forms Controls
Introduction
Part OneFigure- Introducing15-1: TheC#Windowsand theForms.NET Platformcontrol hierarchy
Chapter 1 - The Philosophy of .NET
Figure 15-2: The Form's UI
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Figure 15-3: Interacting with a Form's Controls collection
Chapter 3 - C# Language Fundamentals
ChapterFigure4 -15Object-4: Desig-OrientedtimeProgrammingproperty configurationw th C#
Chapter 5 - Exceptions and Object Lifetime
Figure 15-5: Design time event handling
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 15-6: The many faces of the TextBox type
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeFigure- Programming15-7: The manywithfaces.NETofAssthembliesButton type
Chapter 9 - Understanding .NET Assemblies
Figure 15-8: The initial UI of the CarConfig Form
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 15-9: The CheckedListBox type
Part Four - Leveraging the .NET Libraries
ChapterFigure12 -15Object-10: MulticolumnSerialization andCheckedListBoxthe .NET Remotingtype Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 15-11: The ListBox type
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 15-12: The ComboBox type
Chapter 16 - The System.IO Namespace
ChapterFigure17 -15Data-13:AccessThe MonthCalendarwith ADO.NET type
Part Five - Web Applications and XML Web Services
Figure 15-14: Selecting multiple dates
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Figure 15-15: The VS .NET Tab Order Wizard
Chapter 20 - XML Web Services
IndexFigure 15-16: Associating a ToolTip to a given widget
List of Figures
Figure 15-17: Working with Panel types
List of Tables
Figure 15-18: Working with UpDown types
Figure 15-19: The ErrorProvider in action
Figure 15-20: The AnchoringControls application
Figure 15-21: The main Form
Figure 15-22: The dialog box Form
Figure 15-23: Obtaining information from the dialog box
Figure 15-24: Building the derived Form
Figure 15-25: The Components tab
Figure 15-26: Creating a new Windows Control Library workspace
Figure 15-27:C#Creatingand thethe.NETdesignPlatform,time GUISecond Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Figure 15-28: The client-side GUI |
|
Apress © 2003 (1200 pages) |
|
Figure 15-29:ThisResettingcomprehensivea propertytexttostartsthe defaultwith avaluebrief overview of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 15-30: The custom category
Chapter 16: The System.IO Namespace
Table of Contents
C# and the .NET Platform, Second Edition
Figure 16-1: The Fileand Directory-centric types
Introduction
Part One - Introducing C# and the .NET Platform
Figure 16-2: %windir% directory information
Chapter 1 - The Philosophy of .NET
ChapterFigure2 -16Building-3: BitmapC# Applicationsfile information
Part Two - The C# Programming Language
Figure 16-4: Creating subdirectories
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Figure 16-5: Stream-derived types
Chapter 5 - Exceptions and Object Lifetime
ChapterFigure6 -16Interfaces-6: Readersand andCollectionswriters
Chapter 7 - Callback Interfaces, Delegates, and Events
Figure 16-7: The contents of your *.txt file
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Figure 16-8: Reading from a file
Chapter 9 - Understanding .NET Assemblies
ChapterFigure10 -16Processes,-9: ManipulatingAppDomains,the StringBuilderContexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 16-10: Watching some *.txt files
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 16-11: The car logger application
Chapter 13 - Building a Better Window (Introducing Windows Forms) ChapterFigure14 -16A -Better12: ThePaintingAdd aFrameworkCar dialog(GDI+)box
Chapter 15 - Programming with Windows Forms Controls
Figure 16-13: The standard File Save dialog box
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
PartChapterFive - Web17:ApplicationsData andAccessXML WebwithServicesADO.NET
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapterFigure19 -17ASP-1:.NETADOWeb.NETApplicdatationsproviders provide access to a given DBMS.
Chapter 20 - XML Web Services
IndexFigure 17-2: Exercising a DataColumn type
List of Figures
Figure 17-3: Auto-incrementation of a DataColumn
List of Tables
Figure 17-4: Examining row state
Figure 17-5: The structure of an ADO.NET DataTable
Figure 17-6: The DataTable under construction
Figure 17-7: The visual representation of the DataTable
Figure 17-8: Removing rows from the DataTable
Figure 17-9: Specifying a filter
Figure 17-10: Filtered data
Figure 17-11: Specifying a range of data
Figure 17-12: Editing rows in a DataGrid
Figure 17-13: The updated set of BMW autos
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Figure 17-14: Creating multiple views for a single DataTable
Apress © 2003 (1200 pages)
Figure 17-15: The anatomy of a DataSet
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and Figure 17-16:arcTheitecturalCars databaseissues for .NET developers.
Figure 17-17: Navigating data relations
Table of Contents
Figure 17-18: Navigating parent/child relations
C# and the .NET Platform, Second Edition
Introduction
Figure 17-19: The Cars database as XML
Part One - Introducing C# and the .NET Platform
Figure 17-20: The final GUI update
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Figure 17-21: The Cars XML schema file
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Figure 17-22: Reading records with the OleDbDataReader
Chapter 4 - Object-Oriented Programming with C#
Figure 17-23: Mapping database column names to unique display names
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Figure 17-24: Inserting new records using a data adapter
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# TypeexistingCo strecordsuction Techniques
Figure 17-25: Updating using a data adapter
Part Three - Programming with .NET Assemblies
Figure 17-26: All good things do come ...
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Figure 17-27: Viewing related DataTables
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Figure 17-28: Adding a new data connection
Chapter 12 - Object Serialization and the .NET Remoting Layer
Figure 17-29: Configuring the new data connection
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Figure 17-30: Interacting with the Cars database via VS .NET
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Figure 17-31: Design time connection configuration
Chapter 17 - Data Access with ADO.NET
Figure 17-32: Specifying the connection for the new SqlDataAdapter
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Figure 17-33: Specifying data store updates
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Figure 17-34: Creating the initial SELECT logic
Index
Figure 17-35: Altering column display names at design time
List of Figures
List of Tables
Figure 17-36: Creating a typed DataSet at design time
Figure 17-37: Typed DataSets have a related "code behind" file
Figure 17-38: The DataSet-derived type maintains a set of nested classes.
Chapter 18: ASP.NET Web Pages and Web Controls
Figure 18-1: The HTTP request and response cycle
Figure 18-2: The IIS applet
Figure 18-3: The Cars virtual directory
Figure 18-4: The HTML Controls Toolbox
Figure 18-5: Editing an HTML document via VS .NET
Figure 18-6: C#Theandinitialthecrack.NETatPlatform,the defaultSecond.htm pageEdition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 18-7: Capturing HTML widget events a la VS .NET
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
Figure 18-8: The dynamically generated HTML
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Figure 18-9: Your first ASP.NET Web application
Figure 18-10: The location of the dynamically created assembly
Table of Contents
C# andFigurethe .NET18-11:Platform,*.aspxSecondfiles becomeEditionclasses that extend System.Web.UI.Page.
Introduction
Figure 18-12: The ASP.NET compilation cycle
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Figure 18-13: Creating an ASP.NET application project with VS .NET
Chapter 2 - Building C# Applications
Part TwoFigure- The18C#-14:ProgrammYour designng Languagetime template
Chapter 3 - C# Language Fundamentals
Figure 18-15: Initial files of an ASP.NET application
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Figure 18-16: The ASP.NET Web Controls Toolbox
Chapter 6 - Interfaces and Collections
ChapterFigure7 -18Callback-17: TheInterfaces,derivationDelegates,of an ASPand.NETventspage
Chapter 8 - Advanced C# Type Construction Techniques
Figure 18-18: The result of calling ClearError()
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Figure 18-19: The result of not calling ClearError()
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterFigure11 -18Type-20:ReflThection,ASP.LateNETBinding,Web controlsand Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Figure 18-21: Panel with contained controls
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 18-22: Enumerating contained widgets
Chapter 14 - A Better Painting Framework (GDI+)
ChapterFigure15 -18Programming-23: A dynamicallywith WindowsgeneratedFormsHTMLControlstable
Chapter 16 - The System.IO Namespace
Figure 18-24: A DataGrid with friendly column names
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Figure 18-25: A DataGrid default paging support
Chapter 18 - ASP.NET Web Pages and Web Controls
ChapterFigure19 -18ASP-26:.NETAnWebeditableApplicationsDataGrid
Chapter 20 - XML Web Services
Figure 18-27: The items to be validated
Index
List of Figures
Figure 18-28: Creating a regular expression via VS .NET
List of Tables
Figure 18-29: Bad data . . .
Figure 18-30: Custom server-side validation GUI prep
Figure 18-31: Using a validation summary
Figure 18-32: The System.Web.UI.HtmlControls hierarchy
Figure 18-33: The GDI+ page UI
Figure 18-34: Serving up dynamic images
Figure 18-35: Logging custom trace messages
Chapter 19: ASP.NET Web Applications
Figure 19-1: The UI for the simple state page
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Figure 19-2: The Global.asax designer |
|
Apress © 2003 (1200 pages)
Figure 19-3: The Application/Session state distinction
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Figure 19-4: The cache application GUI architectural issues for .NET developers.
Figure 19-5: The cache application GUI
Table of Contents
Figure 19-6: Cookie data as persisted under Microsoft IE
C# and the .NET Platform, Second Edition
IntroductionFigure 19-7: The UI of the CookiesStateApp
Part One - Introducing C# and the .NET Platform
Figure 19-8: The persistent cookie data
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Figure 19-9: Viewing cookie data
Part Two - The C# Programming Language
ChapterFigure3 -19C#-10:LanguageThe ServicesFundamentalsapplet
Chapter 4 - Object-Oriented Programming with C#
Figure 19-11: Configuration inheritance
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
ChapterChapter7 - Callback20: XMLInterfaces,WebDelegates,Servicesand Events
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeFigure- Programming20-1: XML Webwithservices.NET Assembliesin action
Chapter 9 - Understanding .NET Assemblies
Figure 20-2: Viewing the functionality of the HelloWorldWS Web service
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Figure 20-3: Web method return values are expressed in terms of XML.
Part Four - Leveraging the .NET Libraries
ChapterFigure12 -20Object-4: ViewingSerializationthe compiledand the ..NETRemotingassemblyLayer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Figure 20-5: Creating a new VS .NET XML Web Service project
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Figure 20-6: Invoking the Add() Web method
Chapter 16 - The System.IO Namespace
ChapterFigure17 -20Data-7: AccessDocumentingwith ADOyour.NETWeb methods
Part Five - Web Applications and XML Web Services
Figure 20-8: The dummy value for your XML namespace is http—//tempuri.org.
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Figure 20-9: The VS .NET Add Web Reference utility
Chapter 20 - XML Web Services
IndexFigure 20-10: A Windows Forms XML Web Service Client application
List of Figures
Figure 20-11: Interacting with a UDDI catalog
List of Tables
Figure 20-12: Obtaining a list of posted weather-centric Web services
C# and the .NET Platform, Second Edition
List of Tables |
ISBN:1590590554 |
by Andrew Troelsen |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
Chapter 1: The Philosophy of .NET
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table 1-1: A Sampling of .NET-Aware Programming Languages
Table Tableof Contents1-2: CTS Class Characteristics
C# and the .NET Platform, Second Edition
Table 1-3: The Intrinsic CTS Data Types
Introduction
Part One - Introducing C# and the .NET Platform
Table 1-4: A Sampling of .NET Namespaces
Chapter 1 - The Philosophy of .NET
ChapterTable2 -1-Building5: ildasmC#.exeApplicationsTree View Icons
Part Two - The C# Programming Language
Table 1-6: Select Links to the Platform-Agnostic Nature of .NET
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 2: Building C# Applications
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Table 2-1: Output Options of the C# Compiler
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Table 2-2: Options of the C# Command Line Compiler
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Table 2-3: A Handful of Useful cordbg.exe Flags
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Table 2-4: Core Project Workspace Types
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Table 2-5: The Structure of a VS .NET Console Application
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Table 2-6: Stock XML Tags
Chapter 14 - A Better Painting Framework (GDI+)
Table 2-7: XML Format Characters
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Table 2-8: C# Preprocessor Directives
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 3: C# Language Fundamentals
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Table 3-1: .NET String Format Characters
Chapter 20 - XML Web Services
Index
Table 3-2: Value Types and Reference Types Side by Side
List of Figures
List ofTableTables3-3: Core Members of System.Object
Table 3-4: System Types and C# Aliases
Table 3-5: C# Relational and Equality Operators
Table 3-6: C# Conditional Operators
Table 3-7: The Full Set of C# Operators
Table 3-8: C# Accessibility Keywords
Table 3-9: C# Parameter Modifiers
Table 3-10: Select Members of System.Array
Table 3-11: Select Members of System.String
Table 3-12: String Escape Characters
C# and the .NET Platform, Second Edition
by Andrew Tro lsen |
ISBN:1590590554 |
Table 3-13: Select static Members of System.Enum |
|
Apress © 2003 (1200 pages)
Chapter 5: ThisExceptionsom rehe siveandtext startsObjectwith a brLifetimeef overvi w of the C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Table 5-1: Core Members of the System.Exception Type
Table 5-2: Select Members of the System.GC Type
Table of Contents
C# and the .NET Platform, Second Edition
IntroductionChapter 6: Interfaces and Collections
Part One - Introducing C# and the .NET Platform
ChapterTable1 -6-The1: CompareTo()Philosophy of .ReturnNET Values
Chapter 2 - Building C# Applications
Table 6-2: Interfaces of System.Collections
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Table 6-3: Classes of System.Collections
Chapter 4 - Object-Oriented Programming with C#
ChapterTable5 -6-Exceptions4: MembersandofObjthectQueueLifetimeType
Chapter 6 - Interfaces and Collections
Table 6-5: Types of the System.Collections.Specialized Namespace
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
PartChapterThree - Programming7: Callbackwith .NETInterfaces,Assembli s Delegates, and Events
Chapter 9 - Understanding .NET Assemblies
ChapterTable10 -7-Processes,1: Select MembersAppDomains,of SystemContexts,.MultcastDelegate/Systemand Thr ads .Delegate
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
PartChapterFour - Leveraging8: Advancedthe .NET LibrariesC# Type Construction Techniques
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Table 8-1: Pointer-Centric C# Operators
Chapter 14 - A Better Painting Framework (GDI+)
Table 8-2: A Summary of C# Keywords
Chapter 15 - Program ing with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Table 8-3: C#-Operator-to-CIL Special Name Roadmap
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Table 8-4: Valid Overloadable Operators
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 9: Understanding .NET Assemblies
Chapter 20 - XML Web Services
Index
Table 9-1: Key Elements of an Assembly Manifest
List of Figures
List ofTableTables9-2: Manifest CIL Tokens
Chapter 10: Processes, AppDomains, Contexts, and Threads
Table 10-1: Select Members of the System.Diagnostics Namespace
Table 10-2: Select Members of the Process Type
Table 10-3: Select Members of the ProcessThread Type
Table 10-4: Select Members of AppDomain
Table 10-5: Events of the AppDomain Type
Table 10-6: Select Types of the System.Threading Namespace
Table 10-7: Key Static Members of the Thread Type
Table 10-8: Select Instance Level Members of the Thread Type
C# and the .NET Platform, Second Edition |
|
|
by Andrew Troelsen |
ISBN:1590590554 |
|
Table 10-9: Members of the Interlocked Type |
|
|
Apress © 2003 (1200 pages) |
|
|
This comprehensive text starts with a brief overview of the |
Attribute-Based |
|
Chapter 11:C#TypelanguageReflection,and then quicklyLatemoves Binding,to key technicalandand |
||
architectural issues for .NET developers. |
|
|
Programming |
|
|
Table 11-1: Select Members of System.Type
Table of Contents
C# and the .NET Platform, Second Edition
Table 11-2: A Sampling of Members of the System.Reflection Namespace
Introduction
Part OneTable- Introducing11-3: A TinyC#Samplingnd the .NETof PredefinedPlatform System Attributes
Chapter 1 - The Philosophy of .NET
Table 11-4: Select Assembly-level Attributes
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 12: Object Serialization and the .NET Remoting Layer
Chapter 3 - C# Language Fundam ntals
Chapter 4 - Object-Oriented Programming with C#
Table 12-1: BinaryFormatter Members
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Table 12-2: System.Runtime.Serialization Namespace Core Types
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Table 12-3: StreamingContextStates Enumeration Members
Part Three - Programming with .NET Assemblies
Table 12-4: The .NET Remoting Namespaces
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Table 12-5: Key Members of System.MarshalByRefObject
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Table 12-6: Configuration Options for MBR Types
Chapter 12 - Object Serialization and the .NET Remoting Layer
Table 12-7: Select Members of the ChannelServices Type
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Table 12-8: Members of the RemotingConfiguration Type
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namthespace
Table 12-9: Members of ILease Interface
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 13: Building a Better Window (Introducing Windows Forms)
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Table 13-1: A Subset of Types Within the System.Windows.Forms Namespace
Chapter 20 - XML Web Services
IndexTable 13-2: Methods of the Application Type
List of Figures
Table 13-3: Core Properties of the Application Type
List of Tables
Table 13-4: Events of the Application Type
Table 13-5: Core Properties of the Control Type
Table 13-6: Select Members of the Control Type
Table 13-7: Events of the Control Type
Table 13-8: Properties of the MouseEventArgs Type
Table 13-9: Properties of the KeyEventArgs Type
Table 13-10: Additional Control Properties
Table 13-11: Additional Control Methods
Table 13-12: Additional Control Properties
Table 13-13:C#Membersand theof.NETthe ContainerControlPlatform, SecondTypeEdition
by Andrew Troelsen |
ISBN:1590590554 |
Table 13-14: Properties of the Form Type |
|
Apress © 2003 (1200 pages) |
|
This comprehensive text starts with a brief overview of the
Table 13-15: Key Methods of the Form Type
C# language and then quickly moves to key technical and
architectural issues for .NET developers.
Table 13-16: Select Events of the Form Type
Table 13-17: Form Life Time Events
Table of Contents
C# andTablethe .13NET-18:Platform,MembersSecofndtheEditionMenu Type
Introduction
Table 13-19: The Nested MenuItemCollection Type
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Table 13-20: More Details of the MenuItem Type
Chapter 2 - Building C# Applications
Part TwoTable- The13-C#21:ProgrammingSelect StatusBarLanguageProperties
Chapter 3 - C# Language Fundamentals
Table 13-22: Properties of the StatusBarPanel Type
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Table 13-23: The Timer Type
Chapter 6 - Interfaces and Collections
ChapterTable7 -13Callback-24: PropertiesInterfaces,of theDelegates,ToolBarandTypeEvents
Chapter 8 - Advanced C# Type Construction Techniques
Table 13-25: Properties of the ToolBarButton Type
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 14: A Better Painting Framework (GDI+)
Chapter 10 - Processes, AppDomains, Con exts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part FourTable- Leveraging14-1: The Corethe .NETGDI+LibrariesNamespaces
Chapter 12 - Object Serialization and the .NET Remoting Layer
Table 14-2: Core Types of the System.Drawing Namespace
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Table 14-3: Enumerations in the System.Drawing Namespace
Chapter 15 - Programming with Windows Forms Controls
Table 14-4: Key Members of the Point(F) Types
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Table 14-5: Key Members of the Rectangle(F) Types
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Table 14-6: Key Members of the Size(F) Types
Chapter 19 - ASP.NET Web Applications
Table 14-7: Members of the Region Class
Chapter 20 - XML Web S rvices
Index
Table 14-8: Members of the Graphics Class
List of Figures
List of Tables
Table 14-9: Stateful Properties of the Graphics Class
Table 14-10: The GDI+ Coordinate Systems
Table 14-11: The GraphicsUnit Enumeration
Table 14-12: Members of the Color Type
Table 14-13: The FontStyle Enumeration
Table 14-14: Members of the FontFamily Type
Table 14-15: The Text Type
Table 14-16: The Classes of System.Drawing.Drawing2D
Table 14-17: The Enumerations of System.Drawing.Drawing2D
Table 14-18: Various SmoothingMode Values
C# and the .NET Platform, Second Edition |
|
by Andrew Troels n |
ISBN:1590590554 |
Table 14-19: Drawing Members of the Graphics Class |
|
Apress © 2003 (1200 pages)
Table 14-20: Pen Properties
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Table 14-21: Dash Styles
architectural issues for .NET developers.
Table 14-22: LineCap Values
Table of Contents
Table 14-23: Fill Methods of the Graphics Type
C# and the .NET Platform, Second Edition
IntroductionTable 14-24: Values of the HatchStyle Enumeration
Part One - Introducing C# and the .NET Platform
Table 14-25: LinearGradientMode Enumeration
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Table 14-26: Members of the Image Type
Part Two - The C# Programming Language
ChapterTable3 -14C#-27:LanguageThe PictureBoxSizeModeF ndamentals Enumeration
Chapter 4 - Object-Oriented Programming with C#
Table 14-28: Add-Centric Methods of the GraphicsPath Class
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Table 14-29: Members of the System.Resources Namespace
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Chapter 15: Programming with Windows Forms Controls
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Table 15-1: Nested ControlCollection Members
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Table 15-2: Members of the TextBoxBase Type
Part Four - Leveraging the .NET Libraries
ChapterTable12 -15Object-3: TextBoxSerializationPropertiesand the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Table 15-4: ButtonBase Properties
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Table 15-5: CheckBox Properties
Chapter 16 - The System.IO Namespace
ChapterTable17 -15Data-6: MonthCalendarAccess with ADOProperties.NET
Part Five - Web Applications and XML Web Services
Table 15-7: DateTime Members
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Table 15-8: ToolTip Members
Chapter 20 - XML Web Services
IndexTable 15-9: TrackBar Properties
List of Figures
Table 15-10: UpDownBase Properties
List of Tables
Table 15-11: DomainUpDown Properties
Table 15-12: NumericUpDown Properties
Table 15-13: Control Properties
Table 15-14: ErrorBlinkStyle Properties
Table 15-15: FormBorderStyle Properties
Table 15-16: AnchorStyles Values
Table 15-17: DockStyle Values
Table 15-18: Select Members of System.ComponentModel
Chapter 16: The System.IO Namespace
C# and the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
Table 16-1: Key Members of the System.IO Namespace
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
Table 16-2: FileSystemInfo Properties
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table 16-3: Key Members of the DirectoryInfo Type
Table 16-4: Select FileAttributes Values
Table of Contents
C# andTablethe .16NET-5:Platform,FileInfo CoreSecondMembersEdition
Introduction
Table 16-6: FileMode Enumeration Values
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Table 16-7: FileAccess Enumeration Values
Chapter 2 - Building C# Applications
Part TwoTable- The16-C#8: FileShareProgrammingEnumerationLanguageValues
Chapter 3 - C# Language Fundamentals
Table 16-9: Abstract Stream Members
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Table 16-10: MemoryStream Core Members
Chapter 6 - Interfaces and Collections
ChapterTable7 -16Callback-11: CoreInterfaces,MembersDelegates,of TextWriterand Events
Chapter 8 - Advanced C# Type Construction Techniques
Table 16-12: TextReader Core Members
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Table 16-13: BinaryWriter Core Members
Chapter 10 - Processes, AppDomains, Contexts, and Threads
ChapterTable11 -16Type-14:Reflection,BinaryReaderLate CoreBinding,Membersand Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Table 16-15: File Menu Options of the CarLogApp Project
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
ChapterChapter14 - A17:BetterDataP intingAccessFram workwith(GDI+)ADO.NET
Chapter 15 - Programming with Windows Forms Controls
ChapterTable16 -17The-1:SystemADO.NET.IO Namespaces
Chapter 17 - Data Access with ADO.NET
Table 17-2: Key Members of the System.Data Namespace
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Table 17-3: Properties of the DataColumn
Chapter 19 - ASP.NET Web Applications
ChapterTable20 -17XML-4: ValuesWeb Servicesof the MappingType Enumeration
Index
Table 17-5: Key Members of the DataRow Type
List of Figures
List of Tables
Table 17-6: Values of the DataRowState Enumeration
Table 17-7: Key Members of the DataTable
Table 17-8: Members of the DataView Type
Table 17-9: Properties of the Mighty DataSet
Table 17-10: Methods of the Mighty DataSet
Table 17-11: Properties of the DataRelation Type
Table 17-12: Key Types of the System.Data.OleDb Namespace
Table 17-13: Core OLE DB Providers
Table 17-14: Members of the OleDbConnection Type
Table 17-15: Members of the OleDbCommand Type
C# and the .NET Platform, Second Edition
Table 17-16:byKeyAndrMembersw Troelsenof the OleDbParameter Type ISBN:1590590554
Apress © 2003 (1200 pages)
Table 17-17: Core Members of the OleDbDataAdapter
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
Table 17-18: Core Types of the System.Data.SqlClient Namespace architectural issues for .NET developers.
Table 17-19: Types of the System.Data.SqlTypes Namespace
Table of Contents
C#Chapterand the .NET18:Platform,ASPSecond.NETEditionWeb Pages and Web Controls
Introduction
Part OneTable- Introducing18-1: CommonC# andHTMLthe .GUINET PlatformTypes
Chapter 1 - The Philosophy of .NET
Table 18-2: ASP.NET Namespaces
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Table 18-3: Core Types of the System.Web Namespace
Chapter 3 - C# Language Fundamentals
ChapterTable4 -18Object-4: Some-Oriented(But NotPr grammingAll) of thewith@PageC# Attributes
Chapter 5 - Exceptions and Object Lifetime
Table 18-5: Initial Project Files
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Table 18-6: Properties of the Page Type
Chapter 8 - Advanced C# Type Construction Techniques
Part ThreeTable-18Program-7: Membersing withof the.NETHttpRequestAssemblies Type
Chapter 9 - Understanding .NET Assemblies
Table 18-8: Properties of the HttpResponse Type
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Table 18-9: Methods of the HttpResponse Type
Part Four - Leveraging the .NET Libraries
ChapterTable12 -18Object-10: TheS rializatiRole ofntheandInit,theLoad,.NET Remotiand Unloadg LayerEvents
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Table 18-11: Select Members of System.Web.UI.Control
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Table 18-12: Properties of the WebControl Base Class
Chapter 16 - The System.IO Namespace
ChapterTable17 -18Data-13:AccessRich WebControlwith ADO.NETWidgets
Part Five - Web Applications and XML Web Services
Table 18-14: The ASP.NET Validation Controls
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Table 18-15: Common Properties of the ASP.NET Validators
Chapter 20 - XML Web Services
Index
Chapter 19: ASP.NET Web Applications
List of Figures
List of Tables
Table 19-1: Core Types of the System.Web Namespace
Table 19-2: Key Members Defined By the System.Web.HttpApplication Type
Table 19-3: Members of the HttpApplicationState Type
Table 19-4: Select Elements of a web.config File
Table 19-5: Attributes of the <trace> Element
Chapter 20: XML Web Services
Table 20-1: XML Web Service-Centric Namespaces
Table 20-2: Members of the System.Web.Services Namespace
Table 20-3: Key Members of the System.Web.Services.WebService Type
Table 20-4: KeyC# andMembersthe .NETof thePlatform,WebMethodAttributeSecond EditionType
by Andrew Troelsen |
ISBN:1590590554 |
Table
Table
20-5: Select Flags of wsdl.exe
Apress © 2003 (1200 pages)
This comprehensive text starts with a brief overview of the
20-6: Web Service Wire Protocols
C# language and then quickly moves to key technical and architectural issues for .NET developers.
Table 20-7: Supported POST and GET Data Types
Table 20-8: Core Members of the SoapHttpClientProtocol Type
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer Chapter 13 - Building a Better Window (Introducing Windows Forms) Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables