Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
HELLO EVERYONE

first.. i have a database...

dbName: Database
tblName: tblUser
FieldNames: UserID, UserPassword, UserType

example:

alc14647, 12345, admin
bti12345, 67890, user
ggt09876, 45673, editor
blah blah blah

my question is... how do i enabled or hide ex.[buttons or lables]
if the user type is logged in?

i have a SEPARATE LOG IN PAGE, and a MASTER PAGE for my layout and the other page is selected MASTER PAGE for the CONTENTS

ex. admin can see or enable to use a certain buttons or lables
and the user can only use or see a specific labels or buttons after log in,

my buttons or labels are

LABEL1
LABEL2
LABEL3
LABEL4
LABEL5
LABEL6
LABEL7
LABEL8
LABEL9

all the labels can see the ADMIN in the MASTER PAGE note[that labels is isn't the ContentPageHolder, i put it in the OUTSIDE]
and the other user can SEE that labels on their SPECIFIC type,

this my CODE for my SEPARATED Log in page and it's in the same project located also[hope you'v gonna get it^_^]

Imports System.Data.OleDb

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim cn As New OleDbConnection
    Dim cmd As New OleDbCommand
    Dim dr As OleDbDataReader

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtUsername.Focus()
        Label1.Text = ""
        Try
            With cn
                If .State = Data.ConnectionState.Open Then .Close()
                .ConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=" &; Server.MapPath("data\database.mdb")
                .Open()
            End With
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub

Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        If txtUsername.Text = "" Or txtPassword.Text = "" Then Exit Sub
        With cmd
            .CommandText = "Select * from tbluser Where userid = '" & Trim(txtUsername.Text) & "' and passid = '" Trim(txtPassword.Text) &"' "
            .Connection = cn
            dr = .ExecuteReader
        End With

        If dr.HasRows Then
            Session("name") = txtUsername.Text 'it will display o the other page, it depends
            Response.Redirect("Main.aspx") 'my main.aspx is connected to my MASTER PAGE and all the other page
        Else
            Label1.Text = ("ERROR! " & txtUsername.Text)
        End If
    End Sub
End Class

what code i'm gonna suppose to do? and where i'm gonna put it??

please.. i need some help...
just to enabled, disabled, visible = TRUE or FALSE the specific ITEM like BUTTONS and LABELS that depends on the USERTYPE...

thank for READING i hope READER's can HELP ME..
THANKS in ADVANCE ^_^
Posted
Comments
GAiXz 4-May-11 22:01pm    
please i need more reply for this POST.... plz.... so that i can get MORE IDEA to fix it.... ^_^

1 solution

I would use PlaceHolder objects, making the lowest-security one always visible, and then making the higher security ones visible based on the user's role. Of course, this is over simplifying the whole thing, but I think you get the picture.
 
Share this answer
 
v2
Comments
GAiXz 4-May-11 10:40am    
T_T i didn't get it... ^_^ i'm new in ASP.NET ^_^ i'm just using it for a WEEK making simple page... ^_^ i'm sorry... can u EXPLAIN it further?? ^_^ hehe
Monjurul Habib 4-May-11 15:36pm    
what does it mean "^_^ hehe" ??
GAiXz 4-May-11 21:03pm    
huh? it means that i'm happy, thats all...
what do you think? wew

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900