Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Setting the visible property of a list item

Posted on 2004-10-29
8
Medium Priority
?
266 Views
Last Modified: 2008-03-17
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?
0
Comment
Question by:James_fl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 28

Assisted Solution

by:mmarinov
mmarinov earned 400 total points
ID: 12446591
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
 

Author Comment

by:James_fl
ID: 12447903
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
 

Author Comment

by:James_fl
ID: 12447942
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:mmarinov
ID: 12448031
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
 
LVL 15

Expert Comment

by:Thogek
ID: 12448337
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
 
LVL 15

Accepted Solution

by:
Thogek earned 1600 total points
ID: 12448387
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
 

Author Comment

by:James_fl
ID: 12448772
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question