Reputation: 51
I have a table that is being use to hold link and image buttons that link the user to other pages on a web site. I want to hide some of these rows depending on the permission the use has. Right now I have:
// Disable buttons if user does not have admin security level
if (Session["SecurityLevel"] != "A")
{
linkbtnNewEmployee.Visible = false;
imgbtnNewEmployee.Visible = false;
linkbtnViewUserActivity.Visible = false;
imgbtnViewUserActivity.Visible = false;
linkbtnEditEmployees.Visible = false;
imgbtnEditEmployees.Visible = false;
linkbtnManageUsers.Visible = false;
imgbtnManageUsers.Visible = false;
}
which will hide the links and buttons, but the table rows still exist. So I have a row or 2 of space between links. I have tried naming rows and using the "rowToHide.style.display = 'none';" command which does not work because it will not recognize the row. The row id shows up in the source code fine, and I use the same ID in the command. Any suggestions? Thanks for your help!
Upvotes: 1
Views: 98
Reputation: 7943
In markup add an Id for the <tr>
and runat="server"
tag , like this:
<tr id="rowToHide" runat="server>
<!-- Contents here -->
</tr>
And in the code set the visible property to false, like this:
// Disable buttons if user does not have admin security level
if (Session["SecurityLevel"] != "A")
{
rowToHide.Visible = false;
linkbtnNewEmployee.Visible = false;
imgbtnNewEmployee.Visible = false;
linkbtnViewUserActivity.Visible = false;
imgbtnViewUserActivity.Visible = false;
linkbtnEditEmployees.Visible = false;
imgbtnEditEmployees.Visible = false;
linkbtnManageUsers.Visible = false;
imgbtnManageUsers.Visible = false;
}
Upvotes: 1