Asp Net Web Forms and Services

To introduce Web Forms and Web Services. The Internet is quickly evolving from today's Web sites that just deliver UI pages to browsers, to a next generation of programmable Web sites that link organizations, applications, services, and devices directly together. These programmable Web sites are more than passively accessed sites they are reusable, intelligent Web Services. Web development becomes almost as simple as Windows-based application development with Visual Basic .NET. Creating Web...

Testing the LogOn Procedure

In this exercise, you will test the LogOn procedure from a simple form. 1. Open frmLogOn in the Code Editor and locate the btnLogOn_Click event procedure. 2. Declare and instantiate a Customer variable called cusCustomer. 3. Call the LogOn method of the cusCustomer object, passing in the text properties of txtEmail and txtPassword as parameters. 4. Display the properties of the cusCustomer object in the appropriate text boxes. Use the information in the following table Text box Property of...

Advantages of Web Server Controls

To provide an ov erview of the features of Web server controls. The second type of control that ASP .NET includes is the Web server control. Automatic Browser Detection Detect capabilities of client and render accordingly Strongly Typed, Consistent Object Model Enables compile-time type checking Server side only using runat server directive < asp textbox id text2 text some text runat server> < asp textbox> Example Calendar or RadioButtonList control In addition to HTML controls, ASP...

Welcome to the Logon Page

Examine the WebForml.aspx file in the HTML view of the HTML Designer, and describe the Page directive at the top of the page and the HTML syntax within the page, including the control declarations. 9. In the design window, double -click btnSubmit to display the Code Editor, and then explain the code in this module. 10. Add the following code to the btnSubmit_Click event handler, and then explain the uses of the session variable and Response object. Session(FullName) txtFullName.Text 1. Add...

Using CType to Convert Data Types

To explain how to use the new CType function. In Visual Basic .NET, you can convert any data type to any other data type by using the CType function._ Use CType to Convert Values from One Data Type to Another Data Type Similar to CStr and CInt in Visual Basic 6.0 You can use the CType function to convert any value from one data type to another data type. If the value is outside the range allowed by the type, an error will occur. The CType function is similar to the CStr and CInt conversion...

Retrieving Security Information

You can discover security information about the caller of a serviced component by using the SecurityCallContext class. This class provides information regarding the chain of callers leading up to the current method call. The static CurrentCall property of the SecurityCallContext class provides access to the following methods and properties. IsCallerInRole method IsUserInRole method Retrieves information about the last user or application in the caller chain that directly called a me thod. The...

Static Function and Static

To explain how to declare static variables in Visual Basic .NET. Static variables must be explicitly declared in Visual Basic .NET. You can place Static in front of any Function or Sub procedure heading Local variables in a static function or static subroutine retain their values between multiple calls Static functions and static subroutines are not supported You must explicitly declare all static variables Check whether students understand static variables, and provide an example of a static...

Using the Sync Lock Statement

To examine the object pooling application 2. Open the ThreadingDemo.sln project in the installfoldeADemoCode Mod09 ThreadingDemo folder. 3. View the code for the frmThreading form, briefly explaining each member. 4. View the code for the ThreadObj class, briefly explaining each member. 2. Click the Without SyncLock button and observe that the results do not match the expected results. 3. Click the With SyncLock button, observe that the results correctly match those expected, and then quit the...

Manipulating Windows Forms

Open the FormsDemo.sln solution in the install folder DemoCode Mod06 FormsDemo folder. 2. Open the Code Editor window for the modMain.vb file. 3. Examine the code in the Sub Main procedure. 2. Click the Center button on the form, and step through the code when execution halts at the preset breakpoint. 3. Click the Auto Scroll button on the form, and step through the code when execution halts at the preset breakpoint. When execution resumes, resize the form vertically so that the scroll bars...

Build Configurations

There are two types of build configurations for Visual Basic .NET projects During the development phase, you may want to build and test your applications by using compiled assemblies. The Debug configuration produces a .pdb file that contains debugging information. Other applications can use this file to debug your code. To assist these other applications, no optimizations are made to your code. Other applications have access to your complete and original code. After testing is completed, you...

Example 1

The following example shows how to declare a variable in one line and instantiate it in a following line. Remember that the Set keyword is no longer needed. 'Declare but do not instantiate yet Dim c1 As TestClass ' Othe r code c1 New TestClass( ) 'Instantiate now Ensure that students are aware of the differences between the behavior of the following statement in Visual Basic .NET as opposed to previous versions of Visual Basic Dim x As New TestClass

Demonstration Structured Exception Handling

To demonstrate how to use structured exception handling. In this demonstration, you will learn how to use structured exception handling in Visual Basic .NET. The step-by-step instructions for this demonstration are in the instructor notes for this module. In this demonstration, you will learn how to use the Try Catch Finally statement to implement structured exception handling. You will also learn how to check values of the System.Exception class and how to throw your ow n exceptions.

Creating Data Structures

In Visual Basic 6.0, you create user-defined types (UDTs) by using Type End Type syntax. In Visual Basic .NET, you create your own data types by creating data structures. To create a data structure, you use the Structure End Structure syntax. The members of UDTs can only contain Public data types. Internal members of a data structure can contain Public, Friend, or Private data types. Therefore, you must declare internal members of a structure w ith one of these access modifiers, as shown in the...

Using Access Modifiers

To describe the access modifiers that are available in Visual Basic .NET. Before looking at the details for defining classes, you need to understand how access modifiers affect classes. Specify Accessibility of Variables and Procedures Accessible only within the type itself. Accessible within the type itself and all namespaces and code within the same assembly. Only for use on class members. Accessible within the class itself and any derived classes. You can use access modifiers to specify the...

What Is the Microsoft NET Platform

To discuss the core services and features provided by the .NET Platform. The .NET Platform consists of several core services and features, as shown on this slide. One goal of this new platform is to simplify Web development. This topic will provide a brief look at the architecture of the .NET Platform. This topic describes the components of the .NET Platform, including the .NET Framework, the .NET Building Block Services, .NET Enterprise Servers, and Microsoft Visual Studio .NET. The .NET...

Microsoft Certified Professional Program

To provide students with information about the Microsoft Certified Professional Program. The Microsoft Certified Professional Program includes these certifications. The Microsoft Certified Professional program includes the following certifications Microsoft Certified Systems Engineer (MCSE) Microsoft Certified Database Administrator (MCDBA) Microsoft Certified Solution Developer (MCSD) Microsoft Certified Professional + Site Building (MCP + Site Building) Microsoft Certified Professional (MCP)...

Maintaining Serverside State

Application Object Maintains Application-level State Application(App StartTime) Now Application(App StartTime) Now Session Object Maintains Session-level State Data for use by a single client browser Data recoverable by means of Windows Service or SQL Server database Session(Session StartTime) Now Some parts of the your Web application may need to maintain cross-request state. For example, a shopping cart application may need to maintain information about a customer order through multiple...

Testing the Serviced Customer Component

In this exercise, you will modify a prewritten test harness application to reference the serviced Customer component. You will then test the application. 2. On the File menu, point to Open, and then click Project. 3. Set the location to installfolder Labs Lab091 Ex03 Starter, click TestHarness.sln, and then click Open. To set a reference to the serviced component assembly 1. On the Project menu, click Add Reference. 2. In the Add Reference dialog box, click Browse, and then locate the install...

Editing Rows

Use the following steps to edit existing rows 1. Call the BeginEdit method of the row. 2. Change the data in the columns. 3. Call EndEdit or CancelEdit to accept or reject the changes. The following example shows how to edit data in an existing column Dim drChangeRow As DataRow drChangeRow.BeginEdit( ) drChangeRow(Tit1e) drChangeRow(Tit1e).ToString & 1 drChangeRow.EndEdit( )

Using the Command Object with Stored Procedures

Many databases will contain stored procedures that you want to execute. Talk through these steps with respect to the code example below. You can also use the Command object to execute stored procedures in a database. You may need to perform some additional steps when preparing the Command to allow for the use of parameters in the stored procedure. Use the following steps to execute a stored procedure with the Command object 2. Set the CommandType property to StoredProcedure. 3. Use the Add...

Garbage Collection

To explain garbage collection and how it affects object lifetime. Garbage collection significantly alters how objects are destroyed. Background Process That Cleans Up Unused Variables Use x Nothing to Enable Garbage Collection Detects Objects or Other Memory That Cannot Be Reached by Any Code (Even Circular References ) No guarantee of when this will happen Potential for resources to be tied up for long periods of time (database connections, files, and so on) You can force collection by using...

Using Default Properties

To explain how you can use default properties in Visual Basic .NET. The syntax for calling the default properties of an object has been updated in Visual Basic .NET. Supports default properties on most objects Use Set to determine whether assignment is referring to the object or the default property Supports default properties only for parameterized properties Do not need to differentiate between object and default property assignments Default properties are commonly used to index into...

Prerequisites

To present and describe the prerequisites for this course. The following prerequisite knowledge is needed for this course. This course requires that you meet the following prerequisites Experience developing applications in Microsoft Visual Basic 4.0 or later Successful completion of Course 1013A, Mastering Microsoft Visual Basic 6 Development, or equivalent knowledge Successful completion of course 1016A Mastering Enterprise Development Using Microsoft Visual Basic 6, or equivalent knowledge...

Review

To reinforce module objectives by reviewing key points. Object-Oriented Programming Concepts Advanced Object-Oriented Programming Concepts The review questions cover some of the key concepts taught in the module._ 1. An actor must be a person that interacts with the system. True or false False. An actor can also be another system or a part of a system. 2. Define the object-oriented term encapsulation. Encapsulation is the hiding of the details about how an object performs various operations. 3....

Assignment Operators

To explain the new assignment operators. Visual Basic .NET supports a simplified syntax for assignment operations. Simplified Variable Assignment Operators Simplified Variable Assignment Operators iResult equals the existing value for iResult, plus 25 Visual Basic .NET provides a shorthand syntax that you can use to assign values to variables. The standard assignment operators are still valid the new syntax is optional. The original syntax and the shorthand version are shown below Original...

Using HTML Controls

Direct Relationship to Preexisting HTML Tags Server side with runat server directive Properties correspond one-to-one with HTML, weakly typed < input type text id text1 value some text runat server> ASP .NET Includes HTML Controls for Commonly Used HTML Elements To explain how to use HTML controls. ASP .NET provides two main types of controls for you to use HTML controls and Web controls. HTML controls have a direct relationship to preexisting HTML tags. The controls are defined by classes...

Variable Scope

Variables accessible to entire procedure Variables only accessible within that block Lifetime of block variable is entire procedure Dim iLooper As Integer 'Procedure level variable Dim iMax As Integer 'Block level variable iMax iLooper MsgBox (iMax) 'This line generates a compiler error To explain the concept of block scope and how it is implemented in Visual Basic .NET. Visual Basic .NET introduces a new level of variable scope into the Visual Basic language block scope. Explain how the...

Dialog Result

Windows Forms allow you to easily create your own customized dialog boxes. You can create customized dialog boxes by setting the DialogResult property for buttons on your form and displaying the form as a dialog box. Once the form is closed, you can use the DialogResult property of the form to determine which button was clicked. The following example shows how to use the DialogResult property of a Windows Form 'The DialogResult property is updated when a button is pressed and the form closed If...

Creating the LogOn Web Forms User Control

In this exercise, you will open a preexisting Web Forms application that allows you to logon as a customer of the system. You will create a LogOn Web Forms user control that uses text boxes and validation controls. This user control allows users to enter their e-mail address and password and then click a Submit button. To open the existing Web Forms application 2. On the File menu, point to Open, and then click Project. 3. Set the location to Error Hyperlink reference not valid. install folder...

Declaring and Initializing Variables and Arrays

To explain how variables and arrays can be declared and initialized. How do you declare variables and arrays in Visual Basic .NET You Can Initialize Variables When You Declare Them You Can Initialize Arrays with a Size, But They Are No Longer Fixed You must dimension arrays in declaration before ReDim Dim Month(12) As Integer 'Creates array with 13 elements 'Initialize the array with 12 elements Dim aMonth( ) As Integer 1,2,3,4,5,6,7,8,9,10,11,12 In Visual Basic .NET, you can use a different...

Materials and Preparation

This section provides the materials and preparation tasks that you need to teach this module. To teach this module, you need the following materials Microsoft PowerPoint file 2373A_01.ppt Module 1, Overview of the Microsoft .NET Platform To prepare for this module, you should Read all of the materials for this module. Read the instructor notes and the margin notes for the module.

Testing the Add Customer Procedure

In this exercise, you will test the AddCustomer procedure from a simple form. To create the Add Customer button code 1. Open frmNew in the Code Editor, and locate the btnNew_Click event procedure. 2. Declare and instantiate a Customer variable called cusCustomer. 3. Call the AddCustomer function of the cusCustomer object, passing in the appropriate values and displaying the return value in a message box. Use the CStr function to convert the integer value to a string. Use the information in the...

Creating the Inherited Form

To explain how to create an inherited form. Creating an inherited form is simple. After you have designed your base form and built the solution, you are ready to begin deriving forms. To do this, you simply add a new item to the project by clicking Inherited Form in the Add New Item window. This will run the Inheritance Picker for you. When inheriting from a base Windows Form, consider the following guidelines carefully Ensure that the base form is as complete as possible. Make any last minute...

Using the MyBase Keyword

Refers to the Immediate Base Class Can Only Access Public, Protected, or Friend Members of Base Class Is Not a Real Object Cannot Be Stored in a Variable Public Class DerivedClass Inherits BaseClass Public Overrides Sub OverrideMethod MsgBox Derived OverrideMethod MyBase.OverrideMethod End Sub End Class You can use the MyBase keyword to access the immediate base class from which a derived class is inheriting. When using MyBase, you should be aware of some limitations It refers only to the...

Achieving Polymorphism

To explain how to use polymorphism in Visual Basic .NET. Visual Basic .NET combines a traditional use of interfaces- to create polymorphism- with the new class inheritance features. Many classes provide the same property or method A caller does not need to know the type of class the object is based on Class implements members of interface Same approach as in Visual Basic 6.0 Derived class overrides members of base class The code shown in the student notes is demonstrated immediately after this...

Justin Time Activation

When just-in-time JIT activation is enabled, an object is automatically instantiated when a method is called on a serviced component activation , and then automatically deactivated when the method is complete deactivation . When this optio n is enabled, an object does not maintain state across method calls, and this increases the performance and scalability of the application. You can override the Activate and Deactivate methods inherited from the ServicedComponent class to perform custom...

Demonstrations

This section provides demonstration procedures that will not fit in the margin notes or are not appropriate for the student notes. Creating a Visual Basic .NET Project 1. Create a new project and point out the various project templates available when creating a Visual Basic .NET project. Remind students of the general purpose of each template. 2. Create a Windows application project named SimpleProject in the install folder DemoCode Mod02 SimpleProject folder. 1. Examine the current project...

Creating a Serviced Component

To examine the object pooling application 1. Open Microsoft Visual Studio .NET. 2. Open the ObjectPoolingComponent.sln project in the install folder DemoCode Mod09 ObjectPoolingComponent folder. 3. View the code for the Pooling class, particularly noting the Imports statement, class-level attributes, and the purpose of each class member. 4. View the code for the NoPooling class, and point out that the class is almost identical to the Pooling class, except that it does not use object pooling....

Using Object Pooling

Object Pooling Allows Objects to Be Created in Advance ObjectPooling Attribute Specifies MinPoolSize and MaxPoolSize ServicedComponent Provides CanBePooled Method lt ObjectPooling Enabled True, MinPoolSize 5, MaxPoolSize 50 gt _ Public Class Account Public Overrides Function CanBePooled As Boolean To examine how components can use object pooling. Various attributes and interfaces enable Visual Basic .NET components to use object pooling._ In Visual Basic .NET, you use the ObjectPooling...

Practice Deriving Classes from Use Cases

To practice deriving classes and attributes from use cases. This practice allows you to work in pairs to derive some classes and attributes from a use case description. Students will work in pairs and then discuss the outcome as a group. While there should not be too many variations in the answers, you should expect different interpretations and be able to explain why a given student answer is correct or incorrect. Expected answers are given in the Instructor Notes for this module. In this...

Checked ListBox

The CheckedListBox control allows you to use a list box with check boxes beside each item. This is a commonly used control in Windows and was previously available through the Style property of a standard ListBox. The following example shows how you can use the Checkedltems property to access the selected items in the list For intTotalChecked 0 To CheckedListBoxl.Checkedltems.Count - 1 .ToString Next

Creating a Windows Installer Project

In this exercise, you will create a Windows Installer project for a client application. This will include the merge module that you created in the previous lab. You will create shortcuts for the application on the desktop and Programs menu and include a ReadMe file in the distribution. 2. On the File menu, point to Open, and then click Project. 3. Browse to the folder, click Customers.sln, and then click Open. 4. In Solution Explorer, right-click Customers, and then click Add Reference. 5....

Module 3 Language and Syntax Enhancements

Demonstration Using Variables and Data Functions, Subroutines, and Properties 21 Lab 3.1 Working with Variables and Exception Handling 36 Demonstration Structured Exception This course is based on the prerelease version Beta 2 of Microsoft Visual Studio .NET Enterprise Edition. Content in the final release of the course may be different from the content included in this prerelease version. All labs in the course are to be completed with the Beta 2 version of Visual Studio .NETEnterprise...

Creating a Setup Project

To explain how to create a setup project. You can use the New Project dialog box to select a project template for your setup project._ You can use the Setup Project and Web Setup Project templates to create Windows Installer packages for Windows-based and Web-based applications, respectively. You specify which of these project types you want to use when you create a new project in Visual Studio .NET. You can also use the Setup Wizard to lead you through the process of gathering the necessary...