473,412 Members | 2,994 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,412 software developers and data experts.

problem with dynamically created labels

Hi,

Three labels are dynamically created. If a certain condition is met, then
label 2 must be hidden.
My problem: if the condition is met, with this code here below, there
remains a gap between label1 and label3. I tried to embed them into
tablecells (<td>) and into <div>, but i couldn't eliminate the gap between
label1 and label3. I tried to put lb2.height="0".

Do you know a way for removing the gap and to get:
ok
ok3

instead of
ok

ok3

Thanks
André

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim lb, lb2, lb3 As Label
Dim lit As LiteralControl
lb = New Label
lb2 = New Label
lb3 = New Label
lb.Text = "ok"
lb2.Text = "ok2"
lb3.Text = "ok3"

if ..... then
lb2.Visible = False
lb2.Height = "0"
end if

form1.Controls.Add(lb)
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
form1.Controls.Add(lb2)
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
form1.Controls.Add(lb3)
End Sub
Jun 27 '08 #1
1 1066
Its your first "New LiteralControl" line of code that's causing the problem.
You should rearrange your code so that can go inside your "if" block.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
http://iPhonePlaza.net
"André" <ss***@nol.dfwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi,

Three labels are dynamically created. If a certain condition is met, then
label 2 must be hidden.
My problem: if the condition is met, with this code here below, there
remains a gap between label1 and label3. I tried to embed them into
tablecells (<td>) and into <div>, but i couldn't eliminate the gap between
label1 and label3. I tried to put lb2.height="0".

Do you know a way for removing the gap and to get:
ok
ok3

instead of
ok

ok3

Thanks
André

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim lb, lb2, lb3 As Label
Dim lit As LiteralControl
lb = New Label
lb2 = New Label
lb3 = New Label
lb.Text = "ok"
lb2.Text = "ok2"
lb3.Text = "ok3"

if ..... then
lb2.Visible = False
lb2.Height = "0"
end if

form1.Controls.Add(lb)
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
form1.Controls.Add(lb2)
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
form1.Controls.Add(lb3)
End Sub
Jun 27 '08 #2

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

Similar topics

1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
10
by: B. Chernick | last post by:
I am using a System.Web.UI.WebControls.Table control on a screen. (Dot Net 1.1) My problem is this: The table is programmatically reconstructed on every postback. Each table row contains two...
9
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
2
by: BillE | last post by:
I need to create a multi-line label dynamically. Since labels aren't multi-line, I'm creating a textbox and making it look like a label with the multiline property set to true. I want to...
4
by: =?Utf-8?B?T2xhbg==?= | last post by:
Hi, I'm trying to dynamically remove labels from a windows form in csharp. I have a foreach loop similar to : foreach(Control c in this.Controls) { c.Dispose(); }
3
by: Mark B | last post by:
I have an MCMS website that I inherited. It was originally built in .NET 1.1 and then ported to .NET 2.0. They built it with inherited base classes to mimic what is now done with master pages. ...
3
by: gediko | last post by:
hi all, i am creating a series of labels, which the number of labels is defined by the user. dim labels( ) as label after learning the number, redim labels(i) then i am changing their...
1
by: karthik25 | last post by:
Hi, The following code creates a tab container, 5 tab panels, buttons, labels. I was able to add event handlers to the button. But how am i supposed to access the dynamically created labels? For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.