Controlling visibility of controls in a single web form for two different user groups
-
Hi, Iam new to .Net programming and this problem is keeping me ideal for last few days. I like to read the Roles list from the configuration file for a particular form to control the visibility of the web controls. My web.Config has authorisation like this: But inside that locatiion i have many forms and in one form i need to make few fields invisible for roles Doctors alone. How can i achieve this? if it is not possible by reading configuration file then please give me some other way of doing it. Am using .Net 1.1. I am looking forward some help. Thanks Renu
-
Hi, Iam new to .Net programming and this problem is keeping me ideal for last few days. I like to read the Roles list from the configuration file for a particular form to control the visibility of the web controls. My web.Config has authorisation like this: But inside that locatiion i have many forms and in one form i need to make few fields invisible for roles Doctors alone. How can i achieve this? if it is not possible by reading configuration file then please give me some other way of doing it. Am using .Net 1.1. I am looking forward some help. Thanks Renu
-
Hi U can use the session variable. When use logs in , set the role of that user in session variable. While displaying the forms, check the value of session variable & display appropriate controls Regards Manish
Hi Manish, Thank you so much for your time. Actually there is another thing i need to consider. I will explain the situation with example: A user may be under more than one user group and each group has different functionality. User1 is under Role1 and Role2 User2 is only under Role2 The specified location can have access by both role1 and role2, but user from only role2 cannot have access to few fields in a page. So far am having user's role saved in FormAuthenticationTicket as DataUser and i need to check their Roles list with the list specified under the configuration tag to make sure the user is only under role2 to invisible the fields. I hope it explains well. Now is it possible reading config file's ? if so, please tell me how. If not could you please give me few other suggestion to achieve it? Expecting reply... Thanks Renu
-
Hi, Iam new to .Net programming and this problem is keeping me ideal for last few days. I like to read the Roles list from the configuration file for a particular form to control the visibility of the web controls. My web.Config has authorisation like this: But inside that locatiion i have many forms and in one form i need to make few fields invisible for roles Doctors alone. How can i achieve this? if it is not possible by reading configuration file then please give me some other way of doing it. Am using .Net 1.1. I am looking forward some help. Thanks Renu
In the ASP.NET 1.0 framework, the Page class has a "User" property. That property has an "IsInRole" method which returns a Boolean value indicating if the logged in user is in the given role. This could be used to set the visibility of your fields:
myControl.Visible = this.User.IsInRole("Doctor");
Jim Conigliaro jconigliaro@ieee.org