Vincent Stack
asked on
How Do I find a control on masterpage from a content page
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(" HyperLinkH omeMaster" ), 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.asp x">Home</a sp:HyperLi nk></li>
<li><a href="index-1.html">Servic es</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">Produ cts</a></l i>
<li><a href="index-3.html">Techno logy</a></ li>
<li><a href="index-4.html">Contac t Us</a></li>
</ul>
</nav>
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("
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.asp
<li><a href="index-1.html">Servic
<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><a href="#">Marketing</a></li
</ul>
</li>
<li class="last"><a href="#">Economics and agriculture</a></li>
</ul>
</li>
<li><a href="products.aspx">Produ
<li><a href="index-3.html">Techno
<li><a href="index-4.html">Contac
</ul>
</nav>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Hard to tell without knowing all the css rules being applied to this control. Easy way to find it is to use IE dev tools (Press F12) and find which rules are applied to your control.
Please ask a new question stating your issue and providing all css rules applied to the page related to hyperlink controls.
Please ask a new question stating your issue and providing all css rules applied to the page related to hyperlink controls.
ASKER