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");
}
                        You can access a Html item as a GenericHtmlControl by adding the runat='Server' attribute to the markup, you can then access the properties programatically as if it were a "normal" ASP.Net UI control.
<li ID="hide" style="display: Block;" runat="Server"><a href="../list.aspx" >list Approval</a></li>
HtmlGenericControl listItem = this.hide as HtmlGenericControl;
if (listItem != null)
    this.hide.style.Add("display", "none");  
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With