PDA

Click to See Complete Forum and Search --> : webusercontrol + session variables


texas
Aug 23rd, 2005, 04:22 PM
my webusercontrol has a series of buttons that direct user to other pages.

what i'm trying to do is limit the number of buttons on the webusercontrol depending on a users security level. any ideas?


ie.

If Session("ULevel") = 2 Then

'only show button.one and button.two

end if

dj4uk
Aug 24th, 2005, 04:19 AM
Hide all buttons by default.

Have a switch statement (select statement in VB.NET) for each level of security which shows the buttons as required. The switch statement should be in the Page_Load method of the web control.

Let me know if you need any other help.

DJ

texas
Aug 24th, 2005, 08:37 AM
Thats just it, how do you show and hide items?

i know if it was a normal item i could just write something like:
me.item.visible = true

dj4uk
Aug 24th, 2005, 08:47 AM
Server-side it's just .Visible = false

e.g. For a Button called btnNew - btnNew.Visible = false

DJ

texas
Aug 24th, 2005, 09:46 AM
it must have been a long day yesterday...

on the page load event of the usercontrol is where i needed to set the buttons = visible, i was trying to do it on each page.


thanks for the help!