troubleshooting Question

How Do I find a control on masterpage from a content page

Avatar of vstack
vstack asked on
ASP.NET
3 Comments1 Solution409 ViewsLast Modified:
Hi Experts,

I am using masterpages with a menu set up via hyperlinks as listitems.

I am trying to reference the hyperlinks to appy the "current" CSS Class. I cannot find the link.  I am using the following in page load but I cannot 'find' the control.

 Dim mpHyperLinkHome As HyperLink = CType(Master.FindControl("HyperLinkHomeMaster"), HyperLink)
            If mpHyperLinkHome Is Nothing Then
                Response.Write("no find the link")

            Else
                mpHyperLinkHome.CssClass = "current"
            End If

..... in Masterpage
<nav>
                <ul class="sf-menu">
                   
                    <li>
                        <asp:HyperLink ID="HyperLinkHomeMaster" runat="server" NavigateUrl="~/Default.aspx">Home</asp:HyperLink></li>
                    <li><a href="index-1.html">Services</a>
                        <ul>
                            <li><a href="#">Production practice</a></li>
                            <li><a href="#">Genetic engineering</a></li>
                            <li><a href="#">Costs and benefits</a>
                                  <ul>
                                      <li><a href="#">Procesing</a></li>
                                    <li><a href="#">Distribution</a></li>
                                    <li><a href="#">Marketing</a></li>
                                </ul>
                            </li>
                            <li class="last"><a href="#">Economics and agriculture</a></li>
                        </ul>
                    </li>
                    <li><a href="products.aspx">Products</a></li>
                    <li><a href="index-3.html">Technology</a></li>
                    <li><a href="index-4.html">Contact Us</a></li>
                </ul>
            </nav>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros