Solved

Set properties for multiple objects at once

Posted on 2011-09-20
3
176 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
[X]
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
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 56

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 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