• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

ASP.NET in Presentation, Business Logic, Data Access & Data

Hi,

I know how the concept works, but i do not know how to implemenent it.
I have seen a lot of URLs but still do not understand the "passing" of variables
or calling of functions from presentation -> BL -> DA -> Data

Can someone give me a brief/simple example with a few "made up" codes
for example:

- Login of User  (txtUser, txtPass) in login.aspx
- Registration of User (txtName, txtEmail, txtPassword) in reg.aspx

How do i implement this?
0
jedistar
Asked:
jedistar
  • 11
  • 6
1 Solution
 
SystemExpertCommented:
Hi,

This the link where 3-tire concept has shown with code

http://www.codeproject.com/aspnet/datier.asp

Thanks
0
 
jedistarAuthor Commented:
i need a brief sample for:

- Login of User  (txtUser, txtPass) in login.aspx
- Registration of User (txtName, txtEmail, txtPassword) in reg.aspx

to learn.
0
 
anvCommented:
1. ur presentation layer contains nothing but only ASPX pages.
2. Code to process on the values passed from presentation is stored in business layer.
3. the business layer code that needs to interact with the database is stored in the data access layer.

say u have created login.aspx page -- > presentation layer.
ur login for vlaidating user is in busioness logic layer.

in login.aspx.cs u would write.. if (Biz.IsUserValid(txtUserName.text, txtPWD.Text)) Response.Redirect("Index.aspx");

in Biz you would have a public static bool IsUserValid(string userName, pwd)
return DAL.ValidateUser(UserName, Pwd)

in DAL
your function/method will interact with the database procedures to validate a user.


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jedistarAuthor Commented:
what abt registration?
0
 
jedistarAuthor Commented:
raftly have an idea with the login now :)
0
 
jedistarAuthor Commented:
any samples of registraion?

when doing registration, do i have to pass all the registration fields by parameters
if i have like 20 parameters, the business logic's function parameters gonna be so long.
0
 
anvCommented:
thru business login..
you can create properties of a class.

ans assign those values to those..properties..
now instead of passing parameters, you just need to those properties to pass as parameters.
0
 
jedistarAuthor Commented:
Ok i created properties in my business logic class "User"
and made it call the Data Access to add it to the db.

But isn't this going against the logic of having a "User" Typed Dataset in my Data Tier
don't i need to use this?
0
 
jedistarAuthor Commented:
Or is Typed Dataset mainly used to store the data "FROM" the database
and not the data "GOING" into the database.

*confused*

(thanks for the help so far)
0
 
anvCommented:
you can user tyyped dataset in both the cases, but that is not required for such simple things.
0
 
jedistarAuthor Commented:
Thanks, i'm getting there i think:

Say i created a typed dataset--- Users.xsd
It contains a dragged table from "Server Explorer" -> User table with attributes like userid,username,email,age,birthdate etc.

My main question, how to use this now to fill data from the database, and pass data to the database,
(some sample codes u can write would be great)

Is this the correct way to declare it?
- Dim typedDs As DataSet OR Dim typedDs As myCompany.Data.Users ?

When returning it from a function, do i declare the function as
- Public Function obtainDetails(ByVal userid as int) As DataSet OR
- Public Function obtainDetails(ByVal userid as int) As Users

Lastly, i notice i can drag multiple tables into a Users.xsd, when do we need multiple tables in a .xsd typed dataset
0
 
anvCommented:
i would suggest you post a new question for these.

Coz they are completely different from your original question.
0
 
jedistarAuthor Commented:
Also, you missed out on one point -> - Login of User  (txtUser, txtPass) in login.aspx

I have done the validation of user, how do i give it credentials so that
my web.config <authentication mode="forms"> recognises the user is authed?

I have this now:

if (Biz.IsUserValid(txtUserName.text, txtPWD.Text))

  // missing codes to give it credentials

  Response.Redirect("Index.aspx");
0
 
anvCommented:
if (Biz.IsUserValid(txtUserName.text, txtPWD.Text))

  FormsAuthentication.RedirectFromLoginPage(some parameter);
0
 
jedistarAuthor Commented:
thanks, what is the some params?
0
 
anvCommented:
FormsAuthentication.RedirectFromLoginPage(userName, true/false);

true / false is whether u want to persiste cookie or not.
0
 
jedistarAuthor Commented:
thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 11
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now