[Solved] add class in master page(code behind) using child page in asp and c# [closed]


FindControl is only able to find server-side controls, not plain HTML tags. In your case it means that you should add attribute runat="server" to the ClientTab div:

<li>
    <a href="https://stackoverflow.com/questions/17292020/Clients.aspx">
        <div id="ClientTab" class="MainNavigationContainerItem" runat="server"> Client</div>
    </a>
</li>

However your code seems to add yet another class tag to this control, which might not be what you are looking for. Most likely what you want to have is

class="MainNavigationContainerItem ClientTabActive"

in which case the second line of your code-behind should look like this:

currdiv.Attributes["class"] = string.Format("{0} {1}", currdiv.Attributes["class"], "ClientTabActive";

1

solved add class in master page(code behind) using child page in asp and c# [closed]