master page control on content page

Posted by kawade on Stack Overflow See other posts from Stack Overflow or by kawade
Published on 2014-08-20T10:15:39Z Indexed on 2014/08/20 10:20 UTC
Read the original article Hit count: 177

Filed under:
|
|

I have got the following code on master page:

<u1>
...............
............
.............
</u1>
<ul>
    <li id="link1" runat="server"><a href="mytestfile.aspx">Test Files</a></li>
    <li id="link2" runat="server"><a href="mylistitemtest.aspx">List Item Test</a></li>
    <li id="link3" runat="server"><a href="Mytest2.aspx">Some Test</a></li>    
</ul> 

I am trying to access the link1 on the content page as:

var pageHandler = HttpContext.Current.CurrentHandler;
         if (pageHandler is System.Web.UI.Page)
         {
             ((System.Web.UI.Page)pageHandler).Master.FindControl("nav_link1").Visible = false;
         }

but i am getting the error as: "Object reference not set to instance of an object"

© Stack Overflow or respective owner

Related posts about c#

Related posts about master-pages