Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set properties for multiple objects at once

Posted on 2011-09-20
3
173 Views
Last Modified: 2012-05-12
I'm building this website that has A LOT of labels and textboxes. I'm wondering if there is a way to set properties for dynamically added controls.

Example of what I'm trying to say:
Dim label1 as New Label
Dim label2 as New Label
Dim label3 as New Label

With label1, label2, label
      .Font.Name = "Arial"
      .Font.Size = 9
      .ForeColor = System.Drawing.ColorTranslator.FromHtml("#333333")
      .Font.Underline = True
End With

label1.ID = "lbl1"
label1.ID = "lbl2"
label1.ID = "lbl3"

Open in new window

0
Comment
Question by:David11011
3 Comments
 
LVL 16

Accepted Solution

by:
disrupt earned 500 total points
ID: 36570778
You can set a cssclass like so:

http://www.w3schools.com/aspnet/prop_webcontrol_style_cssclass.asp

when your dynamically creating them do

TextBox[numhere].CssClass = "Test"
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36570893
have a look at this page... there is a function to clone a control...
so you create one, set properties athen clone it to create others :P

http://forums.asp.net/t/617980.aspx
0
 
LVL 2

Author Closing Comment

by:David11011
ID: 36573918
Exactly what I was looking for. Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question