c# - Making active hyperlink bold and underline asp.net -
i working on asp.net page. have 2 hyperlinks , want make them active ( apply style sheet, make bolder , underline) somehow not doing it.
here html:
<li style="margin-left: 10px"> <asp:literal id="ltrlregiosn" runat="server" text="<%$ resources: hrgeloggedoutmaster, language %>"></asp:literal>: </li> <li class="active1"> <asp:hyperlink id="lang1hyperlink" runat="server" /></li> <li><asp:hyperlink id="lang2hyperlink" runat="server" /></li>
and style sheet is:
<style> .active1{ font-weight: bold; } </style>
and here how trying using code behind:
if (page.currentlanguage == 1) { lang2hyperlink.cssclass = "active1"; lang2hyperlink.font.bold = true; lang2hyperlink.font.underline = true; } else { lang1hyperlink.cssclass = "active1"; lang1hyperlink.font.bold = true; lang1hyperlink.font.underline = true; }
with code, becomes underlined not bold.
here output html:
<li class="active1"> <a id="ctl00_ctl00_languageswitcher_lang1hyperlink" href="/allvacancies.aspx?lang=2">Рус</a></li> <li class="active1"><a id="ctl00_ctl00_languageswitcher_lang2hyperlink" class="active1" href="/allvacancies.aspx?lang=1" style="font-weight:bold;text-decoration:underline;">eng</a></li>
please suggest how fix ?
there's no need set style properties using code behind. when setting cssclass. modify css:
.active1 { font-weight: bold; text-decoration:underline; }
and can set cssclass via code behind:
if (page.currentlanguage == 1) { lang2hyperlink.cssclass = "active1"; } else { lang1hyperlink.cssclass = "active1"; }
one more thing: noticed have set "active1" class on <li>
well:
<li class="active1">
that seems might typo, or @ least confusing you. remove that.
Comments
Post a Comment