ASP.NET By Example
By Steven A Smith, Nick Chase, Glenn Cook, Nathen Grass, Wynn Netherland, Scott
Swigart, and Will Wise
ASP.NET By Example provides a step-by-step introduction to programming
applications using ASP.NET. Concepts are introduced and then followed up with
numerous examples that the reader is encouraged to use to help them better
understand the material. All of the sample code is available online from the
links below, both in VB and C#.
Supporting Materials:
| Chapter | Status | |
|---|---|---|
| Introduction | ||
| No supporting materials. | ||
| Chapter 1: .NET Overview | Ready | |
| An overview of Microsoft's .NET Framework and where ASP.NET fits in. No supporting materials. | ||
| Chapter 2: An Introduction To ASP.NET | Ready | |
| Chapter 2 introduces ASP.NET and includes a brief history of the Active Server Pages architecture from which ASP.NET evolved. Many of ASP.NET's features are noted and compared with Classic ASP, and most of these features are covered in detail later in the book. No supporting materials. | ||
| Chapter 3: Migrating From ASP to ASP.NET | Ready | |
| This chapter provides some simple guidelines for migrating from ASP to ASP.NET, including examples of several common ASP processes and their ASP.NET equivalents. | ||
| Chapter 4: The New ADO - ADO.NET | Ready | |
| ADO.NET replaces Classic ASP's primary data access technology: ADO. In this chapter you learn how to take advantage of this new and powerful object model. | ||
| Chapter 5: Using ASP.NET Web/HTML Controls | Ready | |
| In this chapter, the built in HTML and Web Controls are introduced and explained, with several examples. | ||
| Chapter 6: Using ASP.NET List Controls | Ready | |
| How to use ASP.NET List Controls, such as the DataList and DataGrid. | ||
| Chapter 7: Using ASP.NET Rich Controls | Ready | |
| How to use the ASP.NET Rich Controls, such as the Calendar and AdRotator. | ||
| Chapter 8: Using ASP.NET Validation Controls | Ready | |
| One of the most useful collections of built-in controls in ASP.NET is the set of Validation Controls. These controls allow ASP developers to forget most of their tedious JavaScript validation writing code, allowing them to spend their time on more important tasks. One of the most powerful validators, the RegularExpressionValidator, is covered in detail with several sample regular expressions provided. Search hot videofor regular expressions at http://RegExLib.com/. | ||
| Chapter 9: Using ASP.NET User Controls | Ready | |
| Chapter 9 introduces User Controls, which provide developers with a powerful tool for reuse that dwarfs the ASP #include directive in flexibility and usefulness. | ||
| Chapter 10: ASP.NET Applications | Ready | |
| Chapter 10 covers ASP.NET Applications, including how to configure them and handle application-level events. The web.config and global.asax files are introduced and explained in this chapter. | ||
| Chapter 11: ASP.NET and Web Services | Ready | |
| Chapter 11 covers how to build, expose, and consume Web Services, which can be used to allow different applications to communicate with one another over the Internet in a standard fashion. | ||
| Chapter 12: Custom ASP.NET Controls | Ready | |
| Chapter 12 covers the creation of your own custom controls and components using the .NET Framework. | ||
| Chapter 13: Debugging ASP.NET Overview | Ready | |
| ASP.NET's debugging support is greatly improved over Classic ASP's near-total lack of features. Exception handling is consistent and powerful in ASP.NET, and the new Tracing features of ASP.NET eliminate the need for Response.Write debugging techniques. A brief look at event logging and performance counters rounds out this chapter. | ||
| Chapter 14: Case Study in ECommerce with ASP.NET: IBuySpy.com | Source Only | |
|
Many readers will already be familiar with the IBuySpy.com store, a sample
application built by Microsoft and Vertigo to be used as a learning tool for
new ASP.NET developers. In this case study, the IBuySpy Store application is
analyzed, including a discussion of the decisions that went into the design of
the application. The designers of .NET and the IBuySpy store were interviewed
for this chapter.
The IBuySpy samples are available only as source code -- the working site cannot be duplicated and can be found at http://www.IBuySpy.com. |
||
| Appendix A: The ASP.NET Object Model |
|
|
| No Supporting Materials Online. | ||
| Appendix B: The ADO.NET Object Model |
|
|
| No Supporting Materials Online. | ||
| Appendix C: VB.NET Programming Reference |
|
|
| No Supporting Materials Online. | ||
| Appendix D: C# Programming Reference |
|
|
| No Supporting Materials Online. | ||
Lecture 1
Overview of .NET, Visual Studio, Service Oriented Architecture for the Web, Web Services, SOAP, REST, WSDL, UDDI.Introduction to ASP.NET Lecture slides (ppt 246k)
Service Oriented Architectures for the Web Lecture slides (ppt 929k)
Examples from the lecture notes
- Hello World 30 second web service
- integer and string argument passing - marginally more demanding web services
- PHP SOAP client
- Oooops! - someone slipped on the SOAP - try PHP SOAP client
- source code for the PHP SOAP client
Web Forms (zip 1.6M) and Data Access (zip 960k) - more faculty material from Microsoft - don't forget to wear protective clothing and handle with caution.
Lecture 2
Introduction to Microsoft Visual Studio Lecture slides (ppt 2.5M) using Visual Studio to create a web service, a windows application that uses a web service and a web application using web forms.- Hello World 3 minute web service
- Temperature conversion 5 minute web service
- Temperature converter windows application using the temperature conversion web service
- Temperature converter PHP web application using the temperature conversion web service GET protocol
- CalcTempGETclient.php source code
- Temperature converter PHP web application using the temperature conversion web service SOAP protocol
- CalcTempSOAPclient.php source code
- useCTajax.html JavaScript example using DOM programming to create an AJAX behaviour accessing the web service
- useCTajax.html The same application but running from staffweb. Check the error message
- useCT-XMLHttpRequest.html JavaScript example using an XMLHttpRequest object to access the web service
- Desk calculator 10 minute web application with validation
- turn off client JavaScript to see the server side validation working
Lecture 3
More Microsoft Visual Studio Lecture slides (ppt 2.5M) data binding and database driven web services icluding XML aggregation and interoperability with PHP.- Data binding to GUI components
- SQL Binding to a Data Grid
- Telephone directory as various web services
- Telephone directory as a data set from SQL Server
- Telephone directory as an XML document from SQL Server
- Telephone directory as an XML document from MS Access using OLEDB
- Telephone directory as an XML document read via a data set from MySQL via PHP service
- Telephone directory as an XML document read via an XML text reader from MySQL via PHP web service
- Telephone directory from SQL Server and MySQL via PHP web service merged using XML DOM
- Telephone directory from SQL Server and MySQL via PHP web service merged using a data set
- Telephone directory that fails to attach an XML processing instruction
- Inserting a record into the telephone directory
- Directories merged from SQL Server and MySQL rendered client side with XSLT
- Directories merged from SQL Server and MySQL rendered server side with XSLT
- zip archive containing sources for the above
- Telephone directory as a PHP web service
- Telephone directory merged from MySQL and Access as a PHP web service
- Telephone directory with XSLT processing instruction
- Telephone directory merged from MySQL and SQL Server using SOAP transport
- Telephone directory merged from MySQL and Access with client side XSLT processing
- Telephone directory merged from MySQL and Access using nodeImport() with client side XSLT processing
- Telephone directory merged from MySQL and Access with server side XSLT processing
- XSLT used in the above examples
ASP.NET the EditPlus way
XML and Database connectivity in ASP.NET using EditPlus to cut code. These examples are stuck somewhere between old fashioned ASP and ASP.NET EditPlus is not the way to leverage the power of ASP.NET but these old examples provide simple illustrations of working with XML and MS Access.That old fashioned ASP
- asp4php.doc (116k) Quick Introduction to ASP for PHP users
- intensiveASP.doc (578k) Intensive ASP - 60 pages of good stuff
Tutorial Material
- Make sure that you can replicate all of the examples in the Introduction to ASP.NET PowerPoint - obviously!
- How about writing a short essay comparing and contrasting ASP with ASP.NET. What are the advantages claimed by Microsoft for ASP.NET? Are there any disadvantage?
- What is meant by the term service oriented architecture
- Is SAX available in the DOT.NET framework? Why would you need SAX when you have the XmlTextReader?
Good Stuff
- Guide to using ASP.NET and the Microsoft web servers at Greenwich - essential reading
- ASP.NET - The Official Microsoft ASP.NET 2.0 Site
- Codeplex - Microsoft open source project hosting web site
- AJAX tutorial movies - hosted locally
- otherlinks for .NET - loads of resources and articles about our favourite software house
- Mono - platform independant CLR
- Read all about Amazon web services and life without SOAP from Tim O'Reilly
- Neward and Trenaman consider REST, or The Great and Complete SOAP vs POX Debate
C# Delegates
Delegate Example 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelgateForNotes
{
class Program
{
// Declaring A delegate , which will refer function having two parameter and will return integer
public delegate int AddDelegate(int num1, int num2);
static void Main(string[] args)
{
// Creating method of delegate, and passing Function Add as argument.
AddDelegate funct1= new AddDelegate(Add);
// Invoking Delegate.....
int k=funct1(7,2);
Console .WriteLine(" Sumation = {0}",k);
Console .Read();
}
// Static Function Add, which having same signature as of delegate
public static int Add(int num1, int num2)
{
Console .WriteLine("I am called by Delegate");
int sumation;
sumation= num1+ num2;
return sumation;
}
}
}
Output:
I am called by Delegate
Sumation =9
MultiCast Delegates
A delegate which wrap up more than one method is called Multicast Delegates. When a multicast delegate is get called, it will successively call each functions in order. Multicast Delegate allow to chain together several functions. These chain functions can be called together when delegate is invoked. Every Delegate type has a built in support for dealing with multiiple handlers. Delegate gets this support by inheriting from the MultiCastDelegate class.
To work with Multicast Delegate , delegate signature should return void. Otherwise only last method result can be fetched.
Operators used are
+= this operator is used to add functions in delegate .
-= this operatir is used to remove function from delegate.
Delegate classes
System.Delegate
The purpose of a single delegate instance is very similar to a method pointer from C++. However, in C# don't use method pointers, rather, it save the "metadata" that identifies the target method to call. System.Delegate contains two critical data elements. Firstly, it contains an instance of System.Reflection.MethodInfo â?" in other words, the .NET metadata that enables method invocation using reflection.
The second aspect of System.Delegate is the object instance on which the method needs to be invoked. Given an unlimited number of objects that could support a method that matches the MethodInfo signature, we also need to be able to identify which objects to notify. The only exception is when the method identified by MethodInfo is static â?" in which case the object reference stored by System.Delegate is null.
System.MulticastDelegate
System.MulticastDelegate therefore, adds to delegates the support for notifying multiple subscribers. This is enabled through System.MulticastDelegate's containment of another System.MulticastDelegate instance. On adding a subscriber to a multicast delegate, the MulticastDelegate class creates a new instance of the delegate type, stores the object reference and the method pointer for the added method into the new instance, and adds the new delegate instance as the next item in a list of delegate instances. In effect, the MulticastDelegate class maintains a linked list of delegate objects.
Sequential Invocation
When invoking the multicast delegate, each delegate instance in the linked list is called sequentially. This sequential invocation, however, leads to problems if the invoked method throws an exception or if the delegate itself returns data.
Multicast Delegate Example 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MulticastDelegate1
{
class Program
{
// Decelaring delegate here, which will refer to method having void return type and one string as argument
public delegate void showDelegate(string s);
static void Main(string[] args)
{
showDelegate s = Display;
s += Show;
s("Hello");
s("Scott");
Console .Read();
}
// User Defind static function to display
public static void Display(string title)
{
Console .WriteLine(title);
}
// User defind static function
public static void Show(string title)
{
Console .WriteLine(title);
}
}
}
OUTPUT:
Hello
Hello
Scott
Scott
In the above example, the showDelegate is a delegate, which can refer any method having return type void and one string as parameter. There are two static user defined functions called Display and Show.
Multicast Delegate Example 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MulticastDelegate
{
// user defined class for math operation. This class contains two static method. one method for squre and another method for double the number.
class MathOperation
{
// Multiply by two method, this method multiply number by 2
public static void MultiplyByTwo(double d)
{
double res = d*2;
Console .WriteLine("Multiply: "+res.ToString());
}
// squre number method
public static void Squre(double e)
{
double res = e * e;
Console .WriteLine("Square"+res.ToString());
}
}
class NewProgram
{
// Decelaring delegate called del
public delegate void del(double Qr);
static void Main()
{
// Creating delegate
del d = MathOperation.MultiplyByTwo;
// adding method to del delegate using += operator
d += MathOperation.Squre;
// calling display function. passsing delegate and double value as parameter
Display(d, 2.00);
Display(d, 9.9);
Console .ReadLine();
}
// User defined function to display result and call appropirate operation
static void Display(del action, double value)
{
Console .WriteLine("Result = "+ value);
action(value);
}
}
The above code is implementing multicast delegate. In above code, there is a MathOperationClass, this class is containing two methods. One to double the input parameter and other to make squre of that.
public delegate void del(double Qr);
This is delegate decelaration. It will refer method having one double parameter and will return void.
Display function is taking delegate and double as parameter. This function is displaying the result and calling the delegate.
Article from: http://www.dotnetspark.com/kb/1218-beginners-guide-to-delegates-c-sharp.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DelgateForNotes
{
class Program
{
// Declaring A delegate , which will refer function having two parameter and will return integer
public delegate int AddDelegate(int num1, int num2);
static void Main(string[] args)
{
// Creating method of delegate, and passing Function Add as argument.
AddDelegate funct1= new AddDelegate(Add);
// Invoking Delegate.....
int k=funct1(7,2);
Console .WriteLine(" Sumation = {0}",k);
Console .Read();
}
// Static Function Add, which having same signature as of delegate
public static int Add(int num1, int num2)
{
Console .WriteLine("I am called by Delegate");
int sumation;
sumation= num1+ num2;
return sumation;
}
}
}
Output:
I am called by Delegate
Sumation =9
MultiCast Delegates
A delegate which wrap up more than one method is called Multicast Delegates. When a multicast delegate is get called, it will successively call each functions in order. Multicast Delegate allow to chain together several functions. These chain functions can be called together when delegate is invoked. Every Delegate type has a built in support for dealing with multiiple handlers. Delegate gets this support by inheriting from the MultiCastDelegate class.
To work with Multicast Delegate , delegate signature should return void. Otherwise only last method result can be fetched.
Operators used are
+= this operator is used to add functions in delegate .
-= this operatir is used to remove function from delegate.
Delegate classes
System.Delegate
The purpose of a single delegate instance is very similar to a method pointer from C++. However, in C# don't use method pointers, rather, it save the "metadata" that identifies the target method to call. System.Delegate contains two critical data elements. Firstly, it contains an instance of System.Reflection.MethodInfo â?" in other words, the .NET metadata that enables method invocation using reflection.
The second aspect of System.Delegate is the object instance on which the method needs to be invoked. Given an unlimited number of objects that could support a method that matches the MethodInfo signature, we also need to be able to identify which objects to notify. The only exception is when the method identified by MethodInfo is static â?" in which case the object reference stored by System.Delegate is null.
System.MulticastDelegate
System.MulticastDelegate therefore, adds to delegates the support for notifying multiple subscribers. This is enabled through System.MulticastDelegate's containment of another System.MulticastDelegate instance. On adding a subscriber to a multicast delegate, the MulticastDelegate class creates a new instance of the delegate type, stores the object reference and the method pointer for the added method into the new instance, and adds the new delegate instance as the next item in a list of delegate instances. In effect, the MulticastDelegate class maintains a linked list of delegate objects.
Sequential Invocation
When invoking the multicast delegate, each delegate instance in the linked list is called sequentially. This sequential invocation, however, leads to problems if the invoked method throws an exception or if the delegate itself returns data.
Multicast Delegate Example 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MulticastDelegate1
{
class Program
{
// Decelaring delegate here, which will refer to method having void return type and one string as argument
public delegate void showDelegate(string s);
static void Main(string[] args)
{
showDelegate s = Display;
s += Show;
s("Hello");
s("Scott");
Console .Read();
}
// User Defind static function to display
public static void Display(string title)
{
Console .WriteLine(title);
}
// User defind static function
public static void Show(string title)
{
Console .WriteLine(title);
}
}
}
OUTPUT:
Hello
Hello
Scott
Scott
In the above example, the showDelegate is a delegate, which can refer any method having return type void and one string as parameter. There are two static user defined functions called Display and Show.
Multicast Delegate Example 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MulticastDelegate
{
// user defined class for math operation. This class contains two static method. one method for squre and another method for double the number.
class MathOperation
{
// Multiply by two method, this method multiply number by 2
public static void MultiplyByTwo(double d)
{
double res = d*2;
Console .WriteLine("Multiply: "+res.ToString());
}
// squre number method
public static void Squre(double e)
{
double res = e * e;
Console .WriteLine("Square"+res.ToString());
}
}
class NewProgram
{
// Decelaring delegate called del
public delegate void del(double Qr);
static void Main()
{
// Creating delegate
del d = MathOperation.MultiplyByTwo;
// adding method to del delegate using += operator
d += MathOperation.Squre;
// calling display function. passsing delegate and double value as parameter
Display(d, 2.00);
Display(d, 9.9);
Console .ReadLine();
}
// User defined function to display result and call appropirate operation
static void Display(del action, double value)
{
Console .WriteLine("Result = "+ value);
action(value);
}
}
The above code is implementing multicast delegate. In above code, there is a MathOperationClass, this class is containing two methods. One to double the input parameter and other to make squre of that.
public delegate void del(double Qr);
This is delegate decelaration. It will refer method having one double parameter and will return void.
Display function is taking delegate and double as parameter. This function is displaying the result and calling the delegate.
Article from: http://www.dotnetspark.com/kb/1218-beginners-guide-to-delegates-c-sharp.aspx
Friday, May 14, 2010
To Reference ASP.NET Master Page Content, Content Pages
To Access Content Page TextBox Value in MasterPage:
TextBox txtB = (TextBox)ContentPlaceHolder1.FindControl("txtContentPg");
txtMaster.Text = "Content Page TextBox Value: " + txtB.Text;
To Access Master Page Label Value in ContentPage:
Label l1 = (Label)Master.FindControl("lblMaster");
lblContentPg.Text = "Master Page Label = "+l1.Text;
TextBox txtB = (TextBox)ContentPlaceHolder1.FindControl("txtContentPg");
txtMaster.Text = "Content Page TextBox Value: " + txtB.Text;
To Access Master Page Label Value in ContentPage:
Label l1 = (Label)Master.FindControl("lblMaster");
lblContentPg.Text = "Master Page Label = "+l1.Text;

No comments:
Post a Comment