开发者

HtmlControl changing class

开发者 https://www.devze.com 2023-01-25 13:07 出处:网络
<div ID=\"btnWebL\" runat=\"server\" class=\"left_selected\"></div> <asp:LinkButton ID=\"btnWeb\" runat=\"server\" CssClass=\"center_selected\" OnCli开发者_开发技巧ck=\"btnWeb_Click\"
<div ID="btnWebL" runat="server" class="left_selected"></div>
                <asp:LinkButton ID="btnWeb" runat="server" CssClass="center_selected" OnCli开发者_开发技巧ck="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?


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

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

See the documentation here.


Try this code

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

I hope this will work for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消