Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Conditional webform controls

Reply
Thread Tools

Conditional webform controls

 
 
Jerod Guida
Guest
Posts: n/a
 
      02-09-2005
I am fairly new to asp.net and am using webforms in vb.net. I have read a
lot about authorization to entire pages using role-based security, but I
haven't seen much in regard to role-based security for controls within a
page.

For example, say that I want an aspx page to show a link for "Maintenance"
when the user "John" is logged in but not for anyone else. All users have
authorization to see the aspx page (set in web.config), but how does someone
go about the process of conditionally displaying the link? My question is
generic in that I don't specifically care about the link, rather, I am
looking for something that could be applied to any type of control
(textboxes, buttons, etc) within webforms.

Thanks in advance,
Jerod


 
Reply With Quote
 
 
 
 
Arthur Dent
Guest
Posts: n/a
 
      02-09-2005
You could use either of the following methods, where you have any control
named c:

c.Visible = User.Identity.Name = "AllowedUserName"
- or -
c.Visible = User.IsInRole("MyAllowRole")

You could then combine this with a user control, or a panel to make a whole
block of the page show/hide, instead of just one control.

HTH.

"Jerod Guida" <> wrote in message
news:%...
>I am fairly new to asp.net and am using webforms in vb.net. I have read a
> lot about authorization to entire pages using role-based security, but I
> haven't seen much in regard to role-based security for controls within a
> page.
>
> For example, say that I want an aspx page to show a link for "Maintenance"
> when the user "John" is logged in but not for anyone else. All users have
> authorization to see the aspx page (set in web.config), but how does
> someone
> go about the process of conditionally displaying the link? My question is
> generic in that I don't specifically care about the link, rather, I am
> looking for something that could be applied to any type of control
> (textboxes, buttons, etc) within webforms.
>
> Thanks in advance,
> Jerod
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving value from popup Webform to main Webform? =?Utf-8?B?Vk1J?= ASP .Net 1 10-09-2006 05:15 PM
Using one webform to set a value on another webform =?Utf-8?B?bXN1aw==?= ASP .Net 1 07-12-2006 07:23 PM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Including WebForm Image Control in a Webform Table Control titof ASP .Net 0 07-24-2003 01:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57