Deleting controls on a webpage

D

Dylan Parry

Hi,

I'm writing a site, and I've have several HTML controls, such as UL
elements, that are dynamically populated via the application I'm writing
in C#.

Sometimes there aren't any list items that need to be added to the UL
element, so it's rendered as

<ul id=foo"></ul>

on the page, with no other content inside it. Obviously this isn't so
good, so I was wondering if I could delete the UL element from within my
C# code so that if it's going to be empty I just remove it from the page?

Can this be done? If so, how would I go about it?

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

The opinions stated above are not necessarily representative of
those of my cats. All opinions expressed are entirely your own.
 
D

Dylan Parry

Dylan said:
Obviously this isn't so good, so I was wondering if I could delete
the UL element from within my C# code so that if it's going to be
empty I just remove it from the page?

Ah, it appears that the "Visible" property, when set to false, will do
just what I wanted. I presumed that it would simply set some CSS or
something on that element and would merely hide it rather than remove it.

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

The opinions stated above are not necessarily representative of
those of my cats. All opinions expressed are entirely your own.
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi,

I'm writing a site, and I've have several HTML controls, such as UL
elements, that are dynamically populated via the application I'm writing
in C#.

Sometimes there aren't any list items that need to be added to the UL
element, so it's rendered as

<ul id=foo"></ul>

on the page, with no other content inside it. Obviously this isn't so
good, so I was wondering if I could delete the UL element from within my
C# code so that if it's going to be empty I just remove it from the page?

Can this be done? If so, how would I go about it?

Hi,
Yes, you can check when you populate the controls ( databinding?) and
if the collection has 0 elements set the Visible property to false;

Also, there is a group for ASP.NET where you can get more especific
answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top