简体   繁体   English

cssClass从后面的代码中设置

[英]cssClass set from the code behind

i tried set this <li> 's class from the code behind and id doesnt recognize the method cssClass: 我试图从后面的代码中设置此<li>的类,并且id无法识别cssClass方法:

the html: HTML:

<div id='settingNev' >
<ul >
  <li id="L1" class='unactive' runat="server"><a id="A1" onserverclick="show_view1" runat="server"><span>Personal</span></a></li>
  </li>
</ul>
</div>

code behind: 后面的代码:

protected void show_view1(object sender, EventArgs e)
{
    this.MultiView1.ActiveViewIndex = 0;
    L1.cssClass = "active";
}

every thing work except the line L1.cssClass = "active"; 除了行L1.cssClass = "active";之外,所有其他事情都L1.cssClass = "active";

what is the problem? 问题是什么? how do i fix it? 我如何解决它?

Tnx for the help :D Tnx寻求帮助:D

You are accessing HTML controls. 您正在访问HTML控件。 CssClass property won't be available with these controls. 这些控件将不能使用CssClass属性。 You need to use the Attribute . 您需要使用Attribute

myList.Attributes.Add("class","active")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM