473,791 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Separating presentation from data layer

Hi all... I could use a little TLC here for understanding and not for
solving a specific problem... sorry if I've got the wrong group, but I'm
using VB so I figured this was the most appropriate one.

I'm an advanced beginner, but in all of the books and class material I have,
I haven't found something that gets to the point about this... lot's of high
level theoretical talk, but nothing that says things in simple terms.

I'm building an app and want to separate the presentation and data "stuff".
Here's some background on the approach I want to take as I understand it:

In my VS project (an ASP.NET project), I've got 3 important things:

1) Submit.aspx -- this is the presentation "thing". It contains mostly
just web controls. Textboxes, a DateTime control (from a vendor), labels,
and a submit button. For example purposes, let's say the fields are:
FullName, PhoneNumber, DOB.

2) DataLayer.vb -- this is my "data" stuff. It contains a class called
"User" that is a model of the data in my form. So, there are read/write
properties for FullName, PhoneNumber and DOB. Also, there's a method called
"SaveToDB" that does exactly that--- opens a database connection and Inserts
the data into a table.

3) Submit.aspx.vb -- The code-behind for Submit.aspx... there's an event
handler here for the Submit button that:

- instantiates an object based on the User class
- sets the properties of this object using values from the web controls
- calls the SaveToDB method on that object to write the values to the
Database.

My questions are:

1) I might also like to write a couple of other classes, possibly to handle
validity... is it appropriate for me to write them in the DataLayer.Vb? My
confusion is because in Visual Studio, when I add a new item, it refers to
it as a "Class"... is this only supposed to contain ONE class?

2) Is this approach reasonable--- I know this is a small app... just an
example, but if it were a lot bigger (i.e. more controls on the form, more
fields, etc), would this be the right approach? If not, what am I doing
wrong?

3) In an app like this, where you are submitting information in a form, is
it better to postback and hide the form to display success, or is it
considered better practice to submit to a second page and have that page
call my data layer?

Thank you in advance for your time...

Michelle
Nov 23 '05
13 2539
Michelle,

That second page should be the components I described. Pages are only for
communication with your clients in this approach.

If you hide parts or use response.redire cts depends in my opinon how much
the form changes.

However in my opinion should the datalayer never be a page.

Cor
Nov 23 '05 #11
Not really what I meant...

In books, I've seen examples of forms based apps where when you click the
submit button, it hides the form and displays a message rather than what
I've seen in a class asp app where it would use a post to another asp page
which handles the data work and displays a message...

Something like:

' this is on the "data entry form" page
' Panel1 on this page contains the data entry controls (eg: textboxes, etc)
' Panel2 contains a label that says "Congratulation s, your data has been
added to the database"

Sub btnSubmit_Oncli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click
' call the class that does the data work here
Panel1.Hide
Panel2.Visble
End Sub

So is this a normal approach?--- my instinct would be to eliminate the 2
lines that hide and display the panels, but then redirect the user to
another page that displays the message...

M
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP10.phx.gbl...
Michelle,

That second page should be the components I described. Pages are only for
communication with your clients in this approach.

If you hide parts or use response.redire cts depends in my opinon how much
the form changes.

However in my opinion should the datalayer never be a page.

Cor

Nov 23 '05 #12
oops... third line should say "...seen in a classic asp app..."

M

"Michelle" <Nope> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Not really what I meant...

In books, I've seen examples of forms based apps where when you click the
submit button, it hides the form and displays a message rather than what
I've seen in a class asp app where it would use a post to another asp page
which handles the data work and displays a message...

Something like:

' this is on the "data entry form" page
' Panel1 on this page contains the data entry controls (eg: textboxes,
etc)
' Panel2 contains a label that says "Congratulation s, your data has been
added to the database"

Sub btnSubmit_Oncli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click
' call the class that does the data work here
Panel1.Hide
Panel2.Visble
End Sub

So is this a normal approach?--- my instinct would be to eliminate the 2
lines that hide and display the panels, but then redirect the user to
another page that displays the message...

M
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Od******** ******@TK2MSFTN GP10.phx.gbl...
Michelle,

That second page should be the components I described. Pages are only for
communication with your clients in this approach.

If you hide parts or use response.redire cts depends in my opinon how much
the form changes.

However in my opinion should the datalayer never be a page.

Cor


Nov 23 '05 #13
Michelle,

Do not mix up classic asp, windowsform and aspnet with each other, they need
all three different approaches. You could not do with ASP what you can do
with ASPNet and you cannot do with ASPNET what you can do with Windowforms.

I opt in most cases for the dual panel where you use your sample because it
gives me a cleaner application. But both ways are valid.

However this has nothing to do with the data layer.

Just my thought,

Cor
Nov 23 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
9113
by: Michael Rodriguez | last post by:
I have a windows form that makes a call to my BLL to get some data. The windows form has a progress bar component that I would like updated as the data retrieval takes place. However, strictly speaking, the BLL is not supposed to know anything about the presentation layer. Also, since the presentation layer has a reference to the BLL, it won't let me add a reference to the presentation layer from the BLL, it complains about a "circular...
5
1690
by: Learner | last post by:
Hi there, I am just trying to set up 3 tier architecture. When i add my Datalayer project to the Business layer project the methods are exposed to in my business class. But in the similar way when i add the Businesss layer project to my presentation i don't see the methods of BL exposing in my presentation layer. But i see the namspace and also the class of my business class but i don't see the methods! is there any thing i am missing...
8
1810
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some of the patterns (e.g., Model View Presenter) or strategies for separating UI logic from the underlying business rules and data. As I understand it, the general intent of doing this is to reduce dependencies amongst our classes in order to make...
5
1563
by: Ronald S. Cook | last post by:
We have a Windows app which contains UI code and all classes that perform business logic and make calls to database stored procs (located on a database server - i.e. not local to the app). My boss wants to bring all those classes to a business server and out of each instance of the Windows application (i.e. separate into a business tier). I understand that by having the business tier separate from the user tier, we can make changes...
1
1616
by: rbg | last post by:
Hi, I am trying to understand the layering concept with the ASP.NET 2.0 apps. I have a ASP.NET 2.0 Web app which has 3 layers Presentation layer which contains UI elements and Input validation logic
2
1932
by: Ily | last post by:
Hi all I am using Visual studio 2005. Im my project I have a presentation layer, a business layer and a data access layer. From my business layer i have a reference to my data layer. I also have a refeence to my business layer from my presentation layer. Now the weird thing is, I can create a form, and I can add a using
6
14154
by: Dhananjay | last post by:
hello everyone i have got a problem i want to design business layer, data access layer , presentation layer for asp.net using C#.net , can anyone help me to solve this problem. i want some resources to complete this. i am trying very hard. Do you have any idea about website or any links where i can find some examples based on this concept.can you plz provide me , its urgent i want this solution with an example, if u have plz provide me. ...
1
1444
by: | last post by:
I'm querying Index Server to return search results, both regular properties and some custom properties I've created. Index Server has this preference for thinking about information as strings rather than datatypes.If you really work at it, you can configure Index Server to treat the data as, say, sortable DateTime datatypes, or integer datatypes. But I'm finding this a huge pain in the butt, and it bothers me that I'm attaching a bunch of...
1
1545
by: Clark Simpson | last post by:
Hi, Apologies if this is such a simple query but if I have an ASP/.NET Application which I normally access via www.foo.com/myapp on Machine A can I access this application layer machine via a Presentation Layer Machine B via www.mypresentationlayer.com/myapp? In a nutshell I want users to access Machine B on the front end (web) but behind the scenes the actual requests are routed to Machine A. Anyone?
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.