Setting the visible property of a list item

Hi, I have an <ul> which has several <li> inside. My question is: How do I hide / show a specific <li> without creating one <ul> for one <li>, putting the <ul> inside a panel and setting the visible property of that panel?
James_flAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarinovCommented:
Hi James_fl,

have you tried useing Literal control
create literal control for each <li>, and add this <li> inside the control
create <ul>

<ul>
    <asp:Literal Text="<li>your text</li>" id="li1" runat="server" />
    <asp:Literal Text="<li>your text</li>" id="li2" runat="server" />
</ul>

and then hide and show the literals

Regards!
B..M
0
James_flAuthor Commented:
thanks for answering mmarinov.

I need to put a link button on the list. If I put an <asp:linkbutton> tag inside the text attribute, will it render properly?

James
0
James_flAuthor Commented:
so it will be like this:

<asp:Literal id="li1" runat="server" Text="<li><asp:linkbutton id=""btn"" runat=""server"">Link 1</asp:linkbutton></li>"

If I do that, can I manipulate the btn in Visual Studio?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

mmarinovCommented:
i don't think so
the Text property can accept and render only pure html
i've checked and saw ( i didn't know that it is possible )
<ul runat="server" id="as">
  <li runat="server" id="as2">assa
    <asp:HyperLink Runat="server" NavigateUrl="asss" id="we">123</asp:HyperLink></li></ul>

HTH
B..M
0
ThogekCommented:
Are you trying to programmatically decide, from the code-behind file, which <li> elements to display or not display?

Or are you trying to provide the ability to hide/show <li> elements dynamically within the browser (without PostBack) based on some user actions?
0
ThogekCommented:
If it's the former (display or not from code-behind code), then why not something simple like:

    <ul>
        <li runat="server" id="li1">Item #1</li>
        <li runat="server" id="li2">Item #2</li>
        <li runat="server" id="li3">Item #3</li>
    </ul>

And then, in the code-behind file, you'd have:

    protected HtmlGenericControl li1;
    protected HtmlGenericControl li2;
    protected HtmlGenericControl li3;

and wherever you want to make the show-or-not-show decisions

    li1.Visible = true;
    li2.Visible = false;
    li3.Visible = true;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James_flAuthor Commented:
Thogek, your solution works. thanks..

mmarinov, I tried your second solution but it didn't work since it can't find the control. But since your first solution works and it actually answered my question (my fault for not asking specifically), I'll give you also a portion of the point

MOD, please split the point and give 100 point to mmarinov.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.