Solved

Set properties for multiple objects at once

Posted on 2011-09-20
3
169 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
Comment Utility
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
Comment Utility
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
Comment Utility
Exactly what I was looking for. Thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now