473,467 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Label Not Being Added

98 New Member
Thanks a lot friend but a problem does occur is i have added a br tag as well but it is not shown in output plz check:
Expand|Select|Wrap|Line Numbers
  1. TextBox [] textBoxArr;
  2. Label []lbl=new Label[5];
  3. Label lblbr=new Label();
  4.  for(int i = 0; i < textBoxArr.Length - 1; i++)
  5.         {   textBoxArr(x) = New TextBox();
  6.             textBoxArr(x).ID = "myTextBox" + x.ToString();
  7. lbl[i]=new Label();
  8. lbl.Id="myLabel" + i.ToString();
  9. lbl[i].Text="myLabel";
  10. lblbr.Text="<br/>";
  11.             textBoxArr[i].Visible = True;
  12. lbl[i].Visible = True;
  13. lblbr.Visible=True;
  14.  //Initializing the TextBox so that it is not rendered in the browser 
  15.             Pnl_TextBoxes.Controls.Add(textBoxArr[i]); //Adding the TextBox to the Panel that holds the text 
  16.  Pnl_TextBoxes.Controls.Add(lbl[i]);
  17.  Pnl_TextBoxes.Controls.Add(lblbr);
  18.  
  19.         }
  20.  

label and Text Boxes Get added But Break is not There after Addition of these two
Sep 13 '10 #1
1 1178
Frinavale
9,735 Recognized Expert Moderator Expert
You only have 1 lblbr defined....therefore only one label with "<br>" in it will be added to the page. You probably don't notice it because it's at the bottom (under all of the controls).


A Panel control is rendered as an HTML <div> element. These elements are used to group things together. The <div> is placed "on-the-next-line" and anything that comes after the <diV> is also placed "on-the-next-line".

So, I recommend that you put the Textbox and Label within their own Panel and add that Panel to the Pnl_TextBoxes. This will group the TextBox and Label together...and will put each grouping on their own line.

Expand|Select|Wrap|Line Numbers
  1. for(int i = 0; i < textBoxArr.Length - 1; i++)
  2. {  textBoxArr(x) = New TextBox();
  3.    textBoxArr(x).ID = "myTextBox" + x.ToString();
  4.    lbl[i]=new Label();
  5.    lbl.Id="myLabel" + i.ToString();
  6.    lbl[i].Text="myLabel";
  7. //   lblbr.Text="<br/>";
  8.    textBoxArr[i].Visible = True;
  9.    lbl[i].Visible = True;
  10. //   lblbr.Visible=True;
  11.  
  12.   Panel textBoxLabelGroup = new Panel;
  13.   textBoxLabelGroup.ID = "textBoxLabelGroup" + i.ToString();
  14.   textBoxLabelGroup.Controls.Add(textBoxArr[i]);
  15.   textBoxLabelGroup.Controls.Add(lbl[i]);
  16.  
  17.   Pnl_TextBoxes.Controls.Add(textBoxLabelGroup); 
  18. }
Sep 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JJA | last post by:
I would like to know how to expand the width of SELECT boxes with Javascript. These have the MULTIPLE attribute and a SIZE attribute greater than 1 (usually around 10 or so). The OPTION elements...
2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
1
by: mail2madhur | last post by:
I need to display different text on label on click of button. <table> <tr> <td> ?????</td> </tr> <tr> <td> <TEXTAREA id="notesId" name="notesdescDisplay" rows=12 cols=83 value=""></TEXTAREA>...
1
by: jjluna13 | last post by:
Hello, I have two textboxes and one label in a form. I am looking to display the sum of both textboxes in the label on "real time", in fact to execute the sum when I lost the focus of one of the...
5
by: blackwellam | last post by:
Hi, Firstly apologies for asking a similar question to one I know has been covered before but I'm quite new to visual basic and dont really understand the answers or how to get the next step. Im...
5
by: prokopis | last post by:
hi. i need some help with a problem that come up. am using c# with windows applications i have dynamical link labels that appeared on the screen. is it possible to capture the text name of the link...
9
Samishii23
by: Samishii23 | last post by:
So I have a custom tool tip in my program. Its a Panel control that has a few Label controls. I have set my Panel to AutoSize based on content. I tried to use the AutoSize property on one of the...
1
by: Hamayon Hamad | last post by:
I have a dynamic label on my form that has changeable text and want to know how to auto fit a label width to its text every time the text is changed? The lable benlongs to a text box and I want to...
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
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
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.