Re: Hiding labels and textboxs in formview templates according to

you should be aware that even if a label/textbox whatever is invisible - when you add data to it it will end up in viewstate. In addition to not showing the control - it should also not contain data.

Dominick Baier (

Developing More Secure Microsoft ASP.NET 2.0 Applications (

Yes, that worked! Thanks

"Alexey Smirnov" wrote:

On May 14, 10:52 pm, Ann <A...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Yes, I have added the event handler. The problem is it doesn't like
my syntax that I'm using, and I don't know what the correct syntax
should be for the path.

It doesn't like "FormView1.itemtemplate.passphrase.visible" I get
this error: BC30456: 'passphrase' is not a member of

I think, it's simple then

Try something like

Protected Sub passPhrase_Init(ByVal sender As Object, ByVal e As

Dim x As Label = CType(sender, Label)
If (Roles.IsUserInRole("networkServices")) Then
x.visible = True
x.visible = False
End If
End Sub
You can also try to use

<asp:Label ... visible=<% #IsAdmin() %>

Public Sub IsAdmin() as Boolean

If (Roles.IsUserInRole("networkServices")) Then
Return True
Return False
End If
End Sub