Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i hide delete button to users and visible to admin only.
Posted

It can be done using session. When a user login, save it as Session["User"] and for admin Session["Admin"].
After login, write it as
Button.Visible=Session["Admin"]==UserType.Text;

it means your button will be visible only when login will be with admin session.

Regards
Sunil Dhanerwal
 
Share this answer
 
v2
Comments
Sharon 2 22-May-13 1:50am    
i'm doing in windows application..sir ..i have a doubt that while user registration how can i identify it is user or admin.how can i give user type in database.please help me..
Member 13465771 18-Oct-17 2:38am    
but how to use session
Hi,

First the type of user logged in,

On page load :
C#
btnDelete.Visible=false;

ex:
C#
if(session["Usertype"]=="admin")
    {
        btnDelete.Visible=true;

    }
     else
       {

          btnDelete.Visible=false;
       }
 
Share this answer
 
Comments
Sharon 2 22-May-13 1:54am    
i'm doing in windows application..sir ..i have a doubt that while user registration how can i identify it is user or admin.how can i give user type in database.please help me..
Sunil Dhanerwal1 22-May-13 2:23am    
it's very easy. User are many but admin responsibility can be assigned to one or two person. While registration of a user, you must have some criteria which define whether registering user is a normal user or admin!!! If you don't have any criteria, you can simple give them user rights and for admin right, you can do it manually in database.
make a table userinfo which store their userid, password, name, address and usertype. If usertype is "User" button will be hide and if usertype of particular user is "Admin" it can be displayed.
only thing you need to do
When user put his userid and password, you need to fetch usertype of that corresponding id and then check if usertype is user or admin. Store usertype in session ( you can store it in session even in window application).
If usertype is user button. visible=false else true
hope it will help you

Regards
Sunil Dhanerwal
Rockstar_ 22-May-13 2:01am    
ok, You store the usertype in database, fetch the usertype and validate...
Rockstar_ 22-May-13 2:01am    
while registration why do you kept delete button?
Sharon 2 22-May-13 2:43am    
ok thanks to all i done it as you said...thanks..

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