Professional Documents
Culture Documents
NET Component
Objectives
After completing this lab, you will be able to:
• Create a component in Microsoft Visual Studio .NET.
• Add a reference to a component in Visual Studio .NET.
Creating a Class
1. Right click the LabSessions solution file , click on Add and, then on New
Project . Choose the Project Types as Visual Basic Projects and the
Templates as Class Library. Set the Location as “C:\LabSessions\” and
name it as Lab03ClassLib.
Structure BenefitInfo
Dim strName As String
Dim strPage As String
End Structure
2. In the Test class, create a method named GetInfoList that creates an array
of Info structures, fills in the structures with the information that is shown in
the following table, and then returns the array to the calling component.
StrName strPage
Dental dental.aspx
Medical medical.aspx
Life Insurance life.aspx
Response.Write("</table>")
2. Right-click the test.aspx page in Solution Explorer and then click Build and
Browse.
A browser window opens in Visual Studio .NET that displays the test.aspx
page. test.aspx displays all of the options from the component.
Make a change in the component
1. Edit the Test.vb file in the Lab03ClassLib project.
2. Increase the size of the array by one, as shown in the following code:
Dim arBenefits(3) as BenefitInfo
6. Refresh the browser that is displaying the test.aspx page. You should see
the new option. Notice that you did not have to rebuild the Web application,
because it automatically uses the new dynamic-link library (DLL).