如何使用代码隐藏的c#隐藏html列表项
我想隐藏使用C#的“li”标签的html列表项。 但我不能这样做。 在早些时候我只是使用c#隐藏DIV标签。 但我无法隐藏“li”标签。 请帮我这样做。如果可以,请发送您的详细说明……
这是我的部分代码:
this.hide.style.Add("display", "none"); // Error in hide
这是我的HTML代码:
list Approval
请帮我解决这个问题….
将id
和runat="server"
到列表项:
<%-- ... --%>
从后面的代码设置visibility属性(C#示例):
if (someBool) { fooItem.Visible = false; }
您还可以使用此方法来应用/删除样式:
if (someBool) { fooItem.Attributes.Add("class", "foobar"); // or removing a style foobarItem.Attributes.Remove("class"); }
您可以通过将runat =’Server’属性添加到标记来访问Html项目作为GenericHtmlControl ,然后您可以以编程方式访问属性 ,就好像它是“正常”的ASP.Net UI控件一样。
list Approval HtmlGenericControl listItem = this.hide as HtmlGenericControl; if (listItem != null) this.hide.style.Add("display", "none");
//place here your list
使用c#,您可以隐藏面板
上述就是C#学习教程:如何使用代码隐藏的c#隐藏html列表项分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1018492.html