show/hide groups of controls based on role, ASP/jquery

324 Views Asked by At

I've seen folks with similar questions, and there's a very good answer that has to do with building a control adapter. But my situation is a little different:

I have an ASP/VB.NET 2010 site with about 2 dozen pages. Those pages contain up to 40 server controls each. There is a role-based access requirement. So, TextBox1 might be visible to roles 1, 2, 4, 7, and invisible to the other roles.

The brute force method would simply be, for each page, iterate through all the controls and explicitly decide whether to show/hide them based on hard-coded rules, i.e.

    Textbox1.visible = (Session("role") = 1 Or Session("role") = 4 Or Session("role") = 7)

This is certainly doable, but cumbersome to code and maintain. Does anyone have a neat short-cut they can think of? I thought about using custom attributes in the html, but that was a non-starter. The ControlAdapter method won't work.

Seems like this would be a somewhat common problem, so I hope someone's come up with an elegant solution. Thanks

0

There are 0 best solutions below