Using WSDL with the Fibonacci Web Service

Recall from the previous chapter, that an ASP.NET Web Service provides a Web Service Description help page that allows us to interact and test the Web Service through a browser. The help page provides a link called Service Description. This requests the current document, and appends WSDL to the request URL. Selecting the Service Description link provides us with WSDL. The WSDL document that describes the Fibonacci ASP.NET Web Service follows. We implemented the Web Service in both C and VB...

Application Code globalasax

Like ASP, ASP.NET supports a global file for each web application. This file is used as an implementation point for global events, objects, and variables. If you are familiar with classic ASP, you will recognize this file as global.asa. ASP.NET supports a similar file, called global.asax. The code contained in global.asax constitutes part of our application. It does not contain application configuration information - the web.config file deals with this, and is covered in the next chapter....

Adding Modifying Removing and Deleting Rows

We've now looked at all the important techniques available for building DataTable objects within a DataSet, and filling them with data. Next we'll confirm just how easy it is to add and edit the data in our DataSet tables, and then see how we can delete and or permanently remove existing rows. Adding rows to a DataTable was demonstrated in several of the previous examples. The NewRow method of the DataTable object returns a new empty DataRow object for the table. After filling in the values, we...

Using Explicit Parameters with a Stored Procedure

Connection string provider SQLOLEDB.l data s our ce MAN NI NG1 initia I c ata I o g WroxB o ok s u i d a 11 o n wd Comi iiarid Text FindFromlSBN Input Parameter isbn 1ib610D603X Output Parameters T itie 1 Ea r ly Ad opter H ai I sfco mi1 Date 01 10 200100 00 00 I iy.v.T 2002 g'J-u- frm UK arid UBA - f um Jiuk- u u-ASr.hE 1.0 Bj uj BJi'-in (E6N L- 6l0a7-C3-5 The Code for the Explicit Parameters Stored Procedure Example As you'll expect, much of the code is the same as we've used in previous...

Creating the Table

The way that we dynamically create the table is very similar to the way we did it with the HtmlTable server control in the previous chapter. Of course, the object class names are different (TableRow and TableCell instead of HtmlTableRow and HtmlTableCell). We have highlighted the differences between the example in the previous chapter and this one Dim intRows As Integer selRows.Value Dim intCols As Integer selCols.Value Dim intRowCount, intColCount As Integer Control (R & intRowCount & C...

Using the Fibonacci Web Service

Let's look at an example using our Fibonacci Web Service. Before we can create the Web Reference we need to know the location of the WSDL for the Web Service we want to create the reference to. For example, the address of the WSDL for the VB .NET Fibonacci implementation of the ASP.NET Web Service on my server is Next, let's create a new Visual Studio .NET project. Since this book is about ASP.NET, we'll create a new ASP.NET Web Application using Visual Basic .NET as our language. Once Visual...

Using the Validation Controls

The demonstration application we provide includes a page that you can use to experiment with the validation controls open the Other Controls section of the left-hand menu . The page contains several textboxes where you have to enter specific values in order for validation to be successful. If you enter invalid values and then click the Submit button, a summary of all the errors is displayed errer LonLrol emami rai.Hr - MicreisaFt Internet 1 Kplarer I 4 - 0 i l3 I SHidi SjFavDfhE l rtjdia l jB '...

Accessing Complex Data with a Data Reader

We saw in the previous chapter how the DataReader object can be used to quickly and efficiently extract a rowset from a data store. We simply create a Connection object, use it to create a Command object for this connection, and then call the ExecuteReader method of the Command object. It returns the new DataReader object. The example code, like many of the relational data access examples in the previous and in this chapter, uses a separate user control that exposes the specific connection...

Events in Action

To support an event in our textbox control we first define a public event of the type EventHandler called TextChanged public event EventHandler TextChanged or in VB Next, we change the LoadPostData implementation to always return true _value postCollection postDataKey return true This will cause the RaisePostDataChangedEvent to be called, from which we know it is safe to raise events caused by postback. In this method we use the delegate to raise a TextChanged event, assuming there are...

Updating Data with a Data Adapter and Data Set Object

Conn thirl StrHj provider SQI.OLE D B. 1 piJala myrct MANNIN Gi inilial tili leg Wi kQooki uid ifn n jwd SELECT commnd SELECT FROM Bo ohList WHERE ISBN LIKE ,18ftltH 4SW INSHi I fjomnvmd INSERT INTO BookUst ISBN Title , Public tJonDate VftLU E3 , 7 , 1 mm Murmisfid delete from bcoh nt where isbn and is null and Title is huli. on tih an IS null and PublkabonDate IS null OK PuWicationDati IJH gt AI -.MjriirViji UPDATE D liLISt SET ISBN 7 Vi HEBE ISDN AND 7 IS NULL AND Title 15 NULL OR Title J AND...

Page View State

In this new round-trip model of Web Forms, there are potentially more interactions with a server than there would be in a traditional browser-server interaction. But at the core it is still stateless HTTP communication. This means that the server doesn't retain any information about the previous client request, such as values in form fields, or the state of objects instantiated to create the page. This would normally mean that the server is doing a lot of extra work in recreating the page each...

Using the SOAP Header

Let's look at how we use this proxy, along with its SOAP header to send additional data with the Web Service request. The following is a simple ASP.NET page written in VB.NET that uses the proxy lt Import Namespace Simple gt lt script runat server gt Public Sub Page_Load sender As Object, e As EventArgs ' Create a new instance of the UsingSoapHeaders ' proxy class used to call the remote .asmx file Dim soapHeaderExample As New UsingSoapHeaders ' Create a new instance of the mySoapHeader class...

Reading and Writing Files

The File and FileInfo classes provide a number of helper methods that can open and create files. These methods don't actually perform the reading and writing of files, rather they instantiate and return other classes, such as FileStream, for reading and writing bytes of data to and from a file StreamReader for reading characters from a stream StreamWriter class for writing characters to a stream The following code example shows how we can open a text file using the static OpenText method of the...

Sorting the List IComparer and IComparable

Collection classes such as ArrayList and Array use the System.Collections.IComparer interface to determine equality when they are sorting collections. This interface is used to establish if a type instance is less than, equal to, or greater than another type instance and has a single method called Compare public int Compare object x, object y Classes that implement this interface should check for equality between the objects passed in, and return one of the following Any negative value if...

The Code for this Example Page

The page contains the customary lt div gt elements to display the results and messages, and details of any errors that we encounter. It also creates the paths to the existing and new documents, and displays a hyperlink to the existing document. This is identical to the previous example, and we aren't repeating the code here. Instead, we start with the part that loads the existing document into a new XmlDocument object Dim objXMLDoc As New XmlDocument Try objXMLDoc.Load strXMLPath Catch objError...

Locking Down via Configuration Section Handler

If the settings specified in machine.config are acceptable defaults, and we don't want those settings changed by applications that inherit those settings, we can use the optional allowDefinition attribute on the configuration section handler. Let's look at an example. Below are the values taken from machine.config for the sessionState section handler as well as the lt sessionState gt settings. The section handler is highlighted lt xml version 1.0 encoding UTF-8 gt lt configuration gt lt...

Per Request Application Events

Per-request application events are those events raised during each and every request made to an ASP.NET application, such as the beginning or end of the request events Application_OnBeginRequest - The Application_OnBeginRequest event is raised on each request that ASP.NET handles, for example, a page or web service. This is unlike the familiar ASP Application_OnStart event, which is only raised once when the application is started. We can use the Application_OnBeginRequest event to execute code...

Writing a Text Box Control

To understand some of the more advanced development aspects of server control, it is useful to actually write a simple control like a textbox. Although this isn't the most exciting control in the world to write, especially since it already exists, it clearly demonstrates some important aspects that control authors need to understand including Raising events from a control. To render a textbox our server control needs to output an HTML input element with a type attribute containing the value...

The NET Language Compilers

When working within the Visual Studio .NET environment, we don't need to worry about the compiler, because the editor takes care of all that for us. Likewise, when simply developing ASP.NET pages, we can rely on the framework to compile pages as required. However, when building components or controls, we'd want to compile code into a DLL, so we need to know how the compiler works. There is a separate compiler for each language, but luckily you use them all in the same way, and most of the...