Solved

Set properties for multiple objects at once

Posted on 2011-09-20
3
170 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

17 Experts available now in Live!

Get 1:1 Help Now