2010-11-13 73 views
4
<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> 

我想将btnWeb类更改为left_not_selected。HtmlControl更改类

我尝试:

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

但btnWebL没有改变类属性。我怎样才能改变课堂?

回答

9

您应该能够设置class属性,像这样:

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

documentation here

+0

thx这样一个快速的答案。 – senzacionale 2010-11-13 21:58:23

1

试试这个代码

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

我希望这会为你工作。