473,394 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Deleting controls on a webpage

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.
Sep 3 '08 #1
2 1100
Dylan Parry wrote:
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.
Sep 3 '08 #2
On Sep 3, 11:00*am, Dylan Parry <use...@dylanparry.comwrote:
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.
Sep 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Amit Kela | last post by:
I am using ASP with SQL for my database. The problem I have is that even after I have ordered certain items from the shopping cart table on the webpage, I cannot remove them - that is the entire...
2
by: Arjen | last post by:
Hello, I have multiplpe web user controls on one webpage. The web user controls have database interaction. When I click on one of the web user control actions then it does'nt show the data...
2
by: Axel Dahmen | last post by:
Hi, a few weeks ago I had started a thread "Can't dynamically add controls because of <%...%> code blocks". The error mentioned keeps me from inserting an automatically generated navigation menu...
2
by: ALI-R | last post by:
Hi I've created a bunch user comtrols for the footer,header,navigation bar of a webpage ,I have two problems: 1) All the controls are in the folder "Control" of the root and all the images...
3
by: Wayne | last post by:
1. I have created my own class that inherits the textbox (called it CyanFocusTextBox). I put in some code and some new properties. All this works. I build the dll that contains this class...
3
by: jonathan.beckett | last post by:
I have been experimenting with placing user controls (using Windows Forms controls) into an ASP.NET webpage - and am completely stuck. I can get a blank user control to work, but nothing beyond...
3
by: Dylan Parry | last post by:
Hi, I've written a library that uses just one ASPX file to display many different pages, and this single ASPX contains only the bare minimum of HTML, ie. html, head and body elements. Now I have...
7
by: John Morgan | last post by:
I have done a fair amount of programming of ASP.NET 1.1 without poroblem I am now involved in my first project with ASP.NET 2.0 and I am having difficulties with understanding the compilation or...
4
by: sphinney | last post by:
I'm not exactly sure how to start this post. My question is pretty simple, but it will take a little bit of context before I can state it. (And thanks in advance for taking the time to read this!) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.