Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:45:02+00:00 2026-06-07T01:45:02+00:00

I am building a whole bunch of different controls from a database schema. When

  • 0

I am building a whole bunch of different controls from a database schema.
When I run through the controls in my code behind, I want to pass the control and the styles (as a string from the database… eg. “color:white;width:50px;height:10px;”) to a re-usable function.

This is how I thought I should go about it :

 Sub AddStylesToControl(ByRef ctrl As Control, Styles As String)

    'split styles string by semi colon
    Dim StyleArr() As String
    Dim count As Integer
    StyleArr = Styles.Split(";")
    For count = 0 To StyleArr.Length - 1

        '//ctrl.Attributes.Add("style", "color: red;")
        ctrl.Attributes.Add("style", StyleArr(count))
    Next

End Sub

Unfortunately, on the line “ctrl.Attributes.Add(“style”, StyleArr(count))” I get an error:
‘attributes’ is not a member of ‘system.web.ui.control’
I understand what the error means, but does anyone know of a way around this ?

Many thanks,
Scott

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:45:04+00:00Added an answer on June 7, 2026 at 1:45 am

    You should use WebControl rather than Control. WebControl is derived from Control but includes the Attributes property.

    Also, the “style” attribute of the control should contain a single string containing the CSS delimited by ;. So passing the entire string as you have it in your database is enough, you do not need to do any more processing.

    So your function should simply look something like…

    Sub AddStylesToControl(ByRef ctrl As WebControl, ByVal styles As String)
        ctrl.Attributes("style") = styles
    End Sub
    

    I have changed it to a direct setting (rather than Add) as this will overwrite any existing "style". Using Attributes.Add will fail if the "style" already exists in the collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been building a website with a whole bunch of articles in Dutch and
I'm trying to run jetty without building the whole project, but simply point jetty
While building several different projects in QtCreator, I have run across the following build
So I'm building a tool that allows a user to edit a whole bunch
I am building an application in Python and I have my whole package. While
Here is my problem. CONTEXT I'm building a whole system to handle images processing
I'm building a REST API that exposes data as XML. I've got a whole
I would like to avoid building a whole library for just boost::Thread . So
I'm currently building a plugin system using IPluginInterface. The plugins include the whole logic,
I am in the process of building a Chrome extension, and for the whole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.