Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HtmlControl changing class

Tags:

c#

asp.net

<div ID="btnWebL" runat="server" class="left_selected"></div>
                <asp:LinkButton ID="btnWeb" runat="server" CssClass="center_selected" OnClick="btnWeb_Click"
                    Text="<%$ Resources:ViaMura.Web.Default, WebSearchButtonText %>"></asp:LinkButton>
                <div ID="btnWebR" runat="server" class="right_selected"></div>

i want to change btnWeb class to left_not_selected.

I try with:

HtmlControl btnWebL = FindControl("btnWebL") as HtmlControl;

but btnWebL does not have property for changing class. How can i change class?

like image 299
senzacionale Avatar asked Nov 13 '10 21:11

senzacionale


2 Answers

You should be able to set the class attribute like so:

bntWebL.Attributes["class"] = "your_new_class";

See the documentation here.

like image 142
Klaus Byskov Pedersen Avatar answered Oct 12 '22 04:10

Klaus Byskov Pedersen


Try this code

HtmlControl btnWebL = FindControl("btnWebL") as HtmlControl;
bntWebL.Attributes["class"] = "left_not_selected";

I hope this will work for you.

like image 40
Sankalp Avatar answered Oct 12 '22 06:10

Sankalp