如何隐藏HTML列表项<立GT;使用C#代码从背后 [英] how can i hide html list item <li> using c# from code behind
问题描述
我想隐藏的HTML列表项是用C#礼的标签。但我无法做到这一点。在早期我只是隐藏使用C#DIV标签。但我不能隐藏礼的标签。请帮我做到这一点。如果你可以请把你的详细说明...
这是我的部分代码:
this.hide.style.Add(显示,无); //错误在隐藏
这是我的HTML代码:
<李ID =隐藏的风格=显示:块;>< A HREF =../ list.aspx>清单审批< / A>< /李>
请帮我解决这个问题....
添加 ID
和 =服务器
到你的列表项:
<预类=lang-asp.net prettyprint-覆盖>
<李ID =fooItem=服务器>
<% - ...... - %>
< /李>
设置从代码中的可见性属性后面(C#示例):
如果(someBool)
{
fooItem.Visible = FALSE;
}
您也可以用这种方法来应用/删除样式:
如果(someBool)
{
fooItem.Attributes.Add(类,FOOBAR);
//或删除样式
foobarItem.Attributes.Remove(类);
}
I want to hide html list item that is "li" tag using C#. But i can't do this. In earlier i just hide DIV tag using c#. But i can't hide "li" tag. Please help me to do this .If you can please send your detail Explanation...
This is my partial code :
this.hide.style.Add("display", "none"); // Error in hide
This is my html code :
<li ID="hide" style="display: Block;"><a href="../list.aspx" >list Approval</a></li>
Please help me to solve this issue ....
Add an id
and runat="server"
to your list item:
<li id="fooItem" runat="server">
<%-- ... --%>
</li>
Set the visibility property from code behind (C# example):
if (someBool)
{
fooItem.Visible = false;
}
You can also use this approach for applying/removing a style:
if (someBool)
{
fooItem.Attributes.Add("class", "foobar");
// or removing a style
foobarItem.Attributes.Remove("class");
}
这篇关于如何隐藏HTML列表项<立GT;使用C#代码从背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!