0

I am using a MasterPage for my website, with various tabs that are placed in the the header (of the MasterPage). The code for the tabs looks like (written in C#):

<ul id="tabMenu">                 
    <li><asp:HyperLink ID="homeLink" runat="server" onclick="homeButton_Click()" 
         NavigateUrl="~/Default.aspx">Home</asp:HyperLink></li>
</ul>

This of course is a single tab, but the rest are very similar. Clicking this link triggers the homeButton_Click() in the code behind, which looks like:

protected void Button1_Click(object sender, EventArgs e)
{
    homeLink.CssClass.Insert(0, "activeTab");
}

The only difference in the current CSS class to the intended one (activeTab) is the change of the background-image. Currently when I click on this tab the CSS class does not change, and the color stays the same.

Any suggestions as to what I'm doing wrong?

3
  • 1
    you should do: homeLink.CssClass = "activeTab"; not the insert. Commented Nov 16, 2011 at 23:15
  • can you post the HTML source (from the browser) and CSS for this please Commented Nov 16, 2011 at 23:16
  • @DavidePiras I think you have the answer. Commented Nov 16, 2011 at 23:20

2 Answers 2

1

Have you tried setting the css class like this instead:

homeLink.CssClass = "activeTab";
Sign up to request clarification or add additional context in comments.

Comments

1

You can assign cssclass using below code

homeLink.Attributes.Add("class", "abc");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.