If you are using content page and want to hide some menu or row of master page as per access you can do it following way.



Master Page

<%-- Some Code --%>

<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr runat="server" id="trMenu">
<td align="center" width="100px">
<a href="#" >Home</a>
</td>
<td align="center" width="100px">
<a href="aboutus.aspx" >About</a>
</td>
<td align="center" width="100px">
<a href="contact.aspx" >Contact</a>
</td>
</tr>
</table>

<%-- Some Code --%>



Content Page


<%@ Page Title="" Language="C#" MasterPageFile="~/MyMaster.Master" AutoEventWireup="true"
CodeBehind="thispage.aspx.cs" Inherits="projectname.thispage" %>

Content Page Code Behind
C#

HtmlTableRow tr = (HtmlTableRow)Master.FindControl("trMenu");
tr.Visible = false;

Vb

Dim tr as HtmlTableRow  = CType(Master.FindControl("trMenu"), HtmlTableRow)
tr.Visible = false;

Please share and like if you find this page as useful. Your comments are appreciated.

Leave a Reply