Home arrow ASP.NET arrow Page 4 - Class Frameworks in VB .NET
ASP.NET

Class Frameworks in VB .NET


In this article, Eugene shows us how to build reusable class frameworks in VB .NET. This proven technique is the best way to build applications.

Author Info:
By: Eugene Gilerson
Rating: 4 stars4 stars4 stars4 stars4 stars / 62
February 17, 2003
TABLE OF CONTENTS:
  1. · Class Frameworks in VB .NET
  2. · Defining Data Access
  3. · Creating Business Objects
  4. · Presentation Layer
  5. · Conclusion

print this article
SEARCH DEVARTICLES

Class Frameworks in VB .NET - Presentation Layer
(Page 4 of 5 )

Now that the business objects are built, we’re back to our presentation layer – the ASP.NET page. As you will see in a moment, the functions we need to perform on the page are now a breeze because all the logic has already been encapsulated into business and data access components.

First of all, in the Page_Load event of editProduct.aspx page, we will create a new Product object:

objProduct = New Product(Request.Params("ProductID"))

This one line of code initializes objProduct with all information we require for display on the page. Then all we need to do is set the Textbox and Label control values:

txtProductName.Text = objProduct.Name
txtNumUnits.Text = objProduct.NumUnits
txtPrice.Text = Mid(String.Format("{0:c}",objProduct.Price), 2)
lblSupplier.Text = objProduct.Supplier.Name + " (" + objProduct.Supplier.Country + ")"


Notice the use of objProduct.Supplier.propertyName syntax, which very typical for object-oriented frameworks. This is possible because Supplier is exposed as a read-only property of Product class and the information is accurate because each product holds only related-by-ID Supplier object.

When user enters all information and clicks “Update” button, all the code we need to update the database with latest data takes up exactly 4 lines:

objProduct.Name = txtProductName.Text
objProduct.NumUnits = txtNumUnits.Text
objProduct.Price = txtPrice.Text
objProduct.Save


And there it is. The Save function of the Product object will propagate all changes made by users back to the database table automatically. Once the page has redirected back to product list, the users will see the information updated on their screen.
blog comments powered by Disqus
ASP.NET ARTICLES

- How Caching Means More Ca-ching, Part 2
- How Caching Means More Ca-ching, Part 1
- Reading a Delimited File Using ASP.Net and V...
- What is .Net and Where is ASP.NET?
- An Object Driven Interface with .Net
- Create Your Own Guestbook In ASP.NET
- HTTP File Download Without User Interaction ...
- Dynamically Using Methods in ASP.NET
- Changing the Page Size Interactively in a Da...
- XML Serialization in ASP.NET
- Using Objects in ASP.NET: Part 1/2
- IE Web Controls in VB.NET
- Class Frameworks in VB .NET
- Cryptographic Objects in C#: Part 1
- Sample Chapter: Pure ASP.Net

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials