Click here to Skip to main content
15,911,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone. I am using linkbutton. I want to add css active class. How can I add.

What I have tried:

ASP.NET
<ul class="nav" id="side-menu">

                            <li>
                                <a href=".aspx"></li>

                            <li>
                                <a href="Ke.aspx">^__i class="fa fa-suitcase fa-fw"__^</i__^Ürün Grubu</a>
                            </li>

                            <li>
                                <a href=".aspx">^__i class="fa fa-user fa-fw"__^Eleman Ekle</a>
                            </li>

                            <li>
                                <a href=".aspx">^__i class="fa fa-product-hunt fa-fw"__^Ürün Ekle</a>
                            </li>

                            <li>
                                <a href="e.aspx">^__i class="fa fa-user-secret fa-fw"__^Müşteri Ekle</a>
                            </li>


                            <li>
                                <a href=".aspx">^__i class="fa fa-plus fa-fw"__^Proje Ekle</a>
                            </li>

                            <li>

                                <a href="e.aspx">^__i class="fa fa-exchange fa-fw"__^Depo Sipariş </a>
                            </li>




                            <li>
                                <asp:LinkButton PostBackUrl="SiparisEkle.aspx" OnClick="lnkSiparis_Click" ID="lnkSiparis" runat="server">
                                 ^__i class="fa fa-edit fa-fw">
                                 Sipariş ekle
                                


                            </li>



                            <li>
                                <a href=".aspx">^__i class="fa fa-wrench fa-fw">Servis Bilgileri</a>
                            </li>



                            <li>
                                <a href="T.aspx">^__i class="fa fa-users fa-fw">Tedarikçi Ekle</a>
                            </li>

                            <li>
                                <a href=".aspx">^__i class="fa fa-database fa-fw">Depo</a>
                            </li>




                        </ul>
Posted
Updated 5-Dec-16 18:24pm

1 solution

Hello
if you want to add styles and css dynamically to your asp controls in code behind, you can use:

YourControl.Attributes.Add("class", "myclass")
YourControl.Style.Add("background-color", "green")
YourControl.Attributes("bgcolor") = "green"

in the firs code you can add class when your linkbutton is clicked
hope it works
 
Share this answer
 
Comments
Member 12859772 6-Dec-16 8:04am    
I add linkbutton onclick event but When I click first dont add class. When I click second add class. Why do that?

lnkSiparis.CssClass = "active";
Ali Majed HA 6-Dec-16 8:09am    
You may have problem in your code, try to use Fire Bug plugin to see the problem
Member 12859772 6-Dec-16 8:24am    
<asp:LinkButton PostBackUrl="SiparisEkle.aspx" OnClick="lnkSiparis_Click" ID="lnkSiparis" runat="server">

Sipariş ekle





My linkbutton above. How can be a problem?
Ali Majed HA 6-Dec-16 23:19pm    
I meant your whole code, for example, sometimes a "required" field, prevent your page to be post back, it means your link button code is correct, but there is an element need to be valued before post back. you can find these bugs easily by "FireBug" plugin.

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