sequential labels names for next label

I have 8 labels on two lines for displaying icons, though generally, not all the icons would be displayed.  For each icon, I want to determine if that icon is to be displayed, and if it is, I want to use the next label in the sequence.  So if I display the first icon, I'd set LblIcon1 visible to true, and the text would be the html to display icon 1.  Now maybe I don't need to display icons 2 or 3, but I do need to display icon 4.  I want to use LblIcon2 to display it.

My labels are named LblIcon1, LblIcon2, LblIcon3, LblIcon4, LblIcon5, LblIcon6, LblIcon7, LblIcon8.  I also have an integer called iconCount that I increment by one when an icon is displayed.   Is there anyway to do something like ("LblIcon" & iconCount).visible = true?  I could use a case statement to determine the next label to use, but is there a better way?

Diane 

0
Mainship
1/31/2008 3:50:41 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

8 Replies
484 Views

Similar Articles

[PageSpeed] 4
Get it on Google Play
Get it on Apple App Store

You could try

Label lbl=(Label)Page.FindControl("LblIcon" & iconCount.ToString())

 


~ Remember To Mark The Posts Which Helped You As The ANSWER ~
0
dotnetkode
1/31/2008 4:02:53 AM

Thank you, I knew there had to be a way.  But I'm not sure how to use this.  I want to do this:

LblIcon4.Visible = True

How do I do that?

Diane 

0
Mainship
1/31/2008 4:11:22 AM

Dim lbl As Label = DirectCast(Page.FindControl("LblIcon"&iconCount.ToString()), Label)

lbl.Visible = True    (if the iconCount is 4, lbl will lblIcon4, if iconCount is 5 lbl will lblIcon5 and so on) 


~ Remember To Mark The Posts Which Helped You As The ANSWER ~
0
dotnetkode
1/31/2008 4:39:02 AM

 I'm getting an error:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Dim lbl As Label
iconCount = iconCount + 1
lbl = DirectCast(Page.FindControl("LblIcon" & iconCount.ToString()), Label)
lbl.Visible = True
 Diane

0
Mainship
1/31/2008 4:51:18 AM
Hi,
   please check if the LblIcon exist,if so, please add a judgement scentence, you can debuge it steply to look for the wrong point,thank you.
Dim lbl As Label
iconCount = iconCount + 1
if(iconCount<=8)
{
lbl = DirectCast(Page.FindControl("LblIcon" & iconCount.ToString()), Label)
lbl.Visible = True
}

Sincerely,
Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hua
2/1/2008 3:57:28 AM

I tried debugging this, but I still can't get it to work.

Diane 

0
Mainship
2/1/2008 11:16:04 PM

Hi,

   could you provide your detail code of cs and aspx?thank you.


Sincerely,
Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hua
2/3/2008 2:27:13 AM

Hi,

You can try replace Page.FindControl("LblIcon" & iconCount.ToString()) with ParentID.FindControl("LblIcon" & iconCount.ToString()),if it not woks,
could you provide your detail code of cs and aspx?thank you.


Sincerely,
Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hua
2/3/2008 2:30:07 AM
Reply:

Similar Artilces:

How to construct Label names on web form at runtime
I want to access forty Label controls in a table on my web page by using a Do Loop (or whatever) to access each Label control in sequence. I know the Label control names are Label1...Label40. How can I 'construct' the Label control name at runtime? Dim intX, intEnd as Integer Dim strLabelName As String intX = 1 intEnd = 40 Do Until intX > intEnd ' contruct Label name strLabelName = "Label" & Trim(CStr(intX)) strLabelName.Text = "whatever" intX += 1 Loop I realize that referring to the .Text using strLabelName won't work, but I don't...

Justify label text in .net(dynamic label)
 Hi all,        I am working on asp.net. I am creating my lable as dynamic. Justify the text is not coming in "Mozilla" but coming in "IE".I am applying style to lable as l1.Style.Add("TEXT-ALIGN", "justify")For static label is working. my code for static label<div style="TEXT-ALIGN:justify"><asp:label id="lbl_desc" runat="server" CssClass="contents" Width="99%"></asp:label></div> ...

Labels and Labels Oh My...
My question is, is it wise to put all text in labels? I know that when you compile and build the dll's it creates the text and save precompile that the server no longer has to, but is puting every single piece of text in some kind of a label useful?  - km______________________________________"always here and always forever" Hi, if it's not necessary to put it in a label, like for example when you want to translate, I like to suggest that you just put it in like normal text. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as...

GEtting all labels and button name from all form
Hello, is there a way to get all label/button names from all forms ina website, and send them to a db 4 translation? Thanks   What you can do is make a loop through all the controls of the page and then check for each control its type if its Label, button then do what you need. this is done on a page level. regardsBilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP My problem is how to code that browsing thru the controls... Can you help me? Thanks ...

superreview granted: [Bug 307819] HTML <label for> not exposed as name for form controls not in <form> : [Attachment 195496] Simple 1 line patch
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 307819: HTML <label for> not exposed as name for form controls not in <form> https://bugzilla.mozilla.org/show_bug.cgi?id=307819 Attachment 195496: Simple 1 line patch https://bugzilla.mozilla.org/attachment.cgi?id=195496&action=edit ...

superreview requested: [Bug 307819] HTML <label for> not exposed as name for form controls not in <form> : [Attachment 195496] Simple 1 line patch
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 307819: HTML <label for> not exposed as name for form controls not in <form> https://bugzilla.mozilla.org/show_bug.cgi?id=307819 Attachment 195496: Simple 1 line patch https://bugzilla.mozilla.org/attachment.cgi?id=195496&action=edit ...

Accessing a dynamically created label in a label array [C# Web App]
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 example how do i get the text of the label changed when the corresponding button is clicked? I have given the complete code below. Please help me with this. 1 using System; 2 using System.Collections; 3 using System.Configuration; 4 using System.Data; 5 using System.Linq; 6 using System.Web; 7 using System.Web.Security; 8 using System.Web.UI; 9 using System.Web....

Label properties Top and Left..System.Web.UI.WebControls.Label
label control has no top / left properties in properties sheet..look at it.. but does in style builder / position form?..?? I can't reach the style builder programatically to set the label.top=200.. or Label.Left=100 in code. Why no exposed properties? TIA Brian Why don't you use CSS to do this? Or you could also use lblControl.Style.Add(...) or lblControl.Attributes.Add(....) to do it programatically OK!.. thanks..but aren't both of those awkward workarounds to the simple syntax like:       Lbl.Width=200 : lbl.Height=100..  which work now?.. t...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Using Labels in Visual Web Developer 2008. Want to space a line or more on label.
I'm using Visual Web Developer 2008 in Visual Studio 2008 Standard thus I'm not posting in Visual Web Developer 2008 Express. I'm using labels that have lots of text on them and I need to know how to do a carriage return or line feed so there's a line or more spacing between lines of text. Could someone show me the code.  See next post. Here's some code for a label I'm using. How would I get line spacing in the text? <asp:Content ID="Content1" ContentPlaceHolderID="Page1Content" runat="server" >    <asp:La...

Binding web form labels, textboxes to a database
I am trying the followng thing i have an access database, i have the adapter with a ok connection and all my querys are working, what i want to do now is to do data bindings to labels and other things to desplay that data, an hopefully if that's a feature in asp.net, to have a textbox which is bound to a column so when i edit the text of that textbox it changes in the dataset and then when i update, it updates the database... i'm exploring the databindings property of the textbox, i get the text property bound to the column in the database, then on load time i fill the dataset with the ad...

Vb.Net: Displaying hierarchical name in Label
Hi, everyone I'm newbie to asp.net and currently getting mud with how to display something in label I'm thinking to visualize it: CEO>GM>Manager>Supervisor>Worker As example: First of all, there is only "CEO"inside Label1 when user click on a "down"button,Label1 will update into "CEO>GM" user click again on "down",Label1will update again into "CEO>GM>Manager" and so on.. then when user click on "up" button, Label1 will delete the last name in the string Ex: CEO>GM>Manager =====...

How can I make a masked label in web forms?
I'm developing a web site using AJAX and I need to display some data in a label but the data must be displayed with a mask.  For example, if I have two textboxes and I wanna do a sum between then, the label must display the result.  But, I don't know what can I do to use a masked label.   If somebody can help me I'll be very thankful.     Thanks in advanced i dont know if i completely understand you.  you say you need a lable to display a sum but you want it masked?  what exactly do you mean by masked.  a masked label is a la...

want to display time in label in a web form.
hii want to display time in my web form.in windows appl i acheived it.how to do it in web appl.plz help out.mupidi.~ Muppidi Hi,it seems to me that this question's related to this one: http://forums.asp.net/thread/1424926.aspx.If so you can use client side javascript to achieve this: http://webdeveloper.earthweb.com/webjs/jstimedate/ Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

Web resources about - sequential labels names for next label - asp.net.web-forms

Communicating sequential processes - Wikipedia, the free encyclopedia
The theory of CSP itself is also still the subject of active research, including work to increase its range of practical applicability (e.g., ...

SEQUENTIAL (@SEQUENTIAL_app) on Twitter
Sign in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here SEQUENTIAL @ SEQUENTIAL_app ...

Sequential for iPad on the App Store on iTunes
Get Sequential for iPad on the App Store. See screenshots and ratings, and read customer reviews.

VIDEO ROOM 1000 COMPLETE MIX All 1000 videos seen in sequential order! - YouTube
This video is a complete rendition of the "I Am Sitting In A Video Room" project, showing highlights of the complete 1000 iterations of the video. ...

Meredith Signs Licensing Deal with Sequential Brands
Meredith and Sequential Brands Group—which finalized its purchase of Martha Stewart Living Omnimedia earlier this month —have reached a 10-year ...

Play Mattel’s Popular Sequential Card Game With Skip-Bo For iOS
Skip-Bo , the popular sequential card game from Mattel, has a brand new official game for iPhone, iPod touch, and iPad. In November last year, ...

Gender benders and sequential hermaphrodites: How sex is determined
Aurich Lawson / Thinkstock It is easy to regard sex as clear-cut, black and white. We regularly have to check the “male” or “female” box on ...

Report: Audi pushing DOT to allow its sequential LED turn signals
Filed under: Sedan , Government/Legal , Safety , Technology , Audi , Luxury Still in the process of trying to get its trick LED Matrix Beam ...

Martha Stewart Living Omnimedia Acquired by Sequential
Sequential Brands Group has acquired Martha Stewart’s media company, Martha Stewart Living Omnimedia, the two companies said on Monday. The ...

Tackle a Mac's name changing with sequential numbers
If a conflict occurs in sharing services, your Mac may start changing its name and append sequential numbers to the end of it.

Resources last updated: 12/24/2015 3:03:34 AM