Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi
how can i change <<li>> class?

my code:

HTML
<li class="current">
                                <a href="Default.aspx"><div>Anasayfa</div></a>
                                <ul>
                                    <li>
                                        <a href="index-corporate.html"><div>Home - Corporate</div></a>
                                        
                                    </li>
                            <li>
                                <a href="#"><div>Features</div></a>
                                <ul>
                                    <li>
                                        <a href="#"><div>Sliders</div></a>
                                        
                                            </li>
                                        </ul>
                                    </li>


I want to change current class when the button pressed

What I have tried:

nothing different
only thinking how can i do this
Posted
Updated 21-Apr-16 22:59pm

Add the runat=server tag

ASP.NET
<ul>
    <li class="current" id="myLI" runat="server">
        <asp:Button ID="ButtonSubmit" runat="server" OnClick="ButtonSubmit_Click" Text="Submit" />
    </li>
</ul>


code behind

C#
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
    myLI.Attributes["class"] = "newclass";
}
 
Share this answer
 
You can use simple javascript to handle this.
C#
Here is a sample solution.



or use this in Code behind
C#
Id.Attributes.Add("class", "some-class")
 
Share this answer
 
v2
Comments
Member 10525430 22-Apr-16 4:05am    
its not working
[no name] 22-Apr-16 4:43am    
updated the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900