// this piece of code will make the controls visible for 104 role only
if (Global.enforceSecurity)
if (!User.IsInRole("104"))
{
myDataGrid.EditButtonVisible = false;
myDataGrid.AddButtonVisible = false;
myDataGrid.DeleteButtonVisible = false;
}
Vs
// this piece of code will make the controls visible for 104 role only
if (User.IsInRole("104"))
{
myDataGrid.EditButtonVisible = true;
myDataGrid.AddButtonVisible = true;
myDataGrid.DeleteButtonVisible = true;
}
The question, is there any difference in the implementation b/e both codes above? or if you have a better code than what I have presented. please share your code and experience
thanks
Bob
Loading
bob whitePosted Jan 6, 2011, 9:41 AM
Hello again, I just realized that IsInRole() only accept a single parameter, so having this... User.IsInRole("110,101"); will not work
My Question, what if I want to have multiple roles to be able to view the button ...myDataGrid.EditButtonVisible , lets say role 110 and 101 are able to view the edit button, but only 110 can add and delete but Not to edit. How can I apply such security.
and thanks for your help again.
Bob
bob whitePosted Jan 6, 2011, 8:45 AM
Your code suggestion made a better choice. I assume that if a user has multiple roles, I can add it to the code like this
aslDataGrid1.EditButtonVisible = User.IsInRole("110,101");
I thank you very much for your support.
Best regards
Bob
Subhendu DePosted Jan 5, 2011, 11:58 PM
if (Global.enforceSecurity)
{
myDataGrid.EditButtonVisible = User.IsInRole("104");
myDataGrid.AddButtonVisible = User.IsInRole("104");
myDataGrid.DeleteButtonVisible = User.IsInRole("104");
}