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

  • SEARCH
  • Home
  • 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 4126784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:04:40+00:00 2026-05-21T00:04:40+00:00

I am in need of some help. I am building a custom web user

  • 0

I am in need of some help. I am building a custom web user control which is going to be picking colours.

As of right now, it has two [asp:textbox]es on the page (foregroundColour and backgroundColour).

I want my foreground colour to default to “FFFFFF” and my background colour to default to “000000”, AND I the user to be able to specify their own initial values though the tag.

<ucFontChooser id="testchooser" runat="server" foregroundcolor="AABBCC" />

I have two properties that are tied to the textboxes:

[DefaultValue("000000")]
public string ForegroundColor { get { return foregroundColorSelectorHex.Text; } set { foregroundColorSelectorHex.Text = value; } }
[DefaultValue("FFFFFF")]
public string BackgroundColor { get { return backgroundColorSelectorHex.Text; } set { backgroundColorSelectorHex.Text = value; } }

Please note that I am aware that the DefaultValue is only for the visual studio property window and doesn’t actually set any value.

However, I have tried to set the default value by in the constructor of the usercontrol to do:

ForegroundColor = "000000"

This gives me an exception, because at the point of the constructor, the foregroundColorSelectorHex is null.

So if I try and setting the default in the OnInit event, or on *Page_Load* then it simply always uses the default I set and the set property value of “AABBCC” is overwritten.

What is the correct way to do what am I trying?

Thank you.

  • 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-05-21T00:04:41+00:00Added an answer on May 21, 2026 at 12:04 am

    After much debugging, I came up with a solution to do exactly what I need.

    public override string ID
    {
        set
        {
            base.ID = value;
            InitializeProperties();
        }
    }
    
    protected void InitializeProperties()
    {
        ForegroundColor = "000000";
        BackgroundColor = "ffffff";
        EnableBackgroundColor = false;
        PrimaryFont = "Arial";
        SecondaryFont = "Helvetica";
        TertiaryFont = "sans-serif";
    }
    

    the .NET framework will call mycontrol.ID = “bla”, which is when the user controls subcontrols come into context. It is called BEFORE the containing control/page reads the tags attributes and sets the properties.

    Looks hacky, but works great.

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

Sidebar

Related Questions

I need some help building a table(s) for a music database in MySQL. I
I need some help building an Query. I have a table Orders with 3
I need some help in building a flexible html layout. I've defined minimum and
Hey. I urgently need some help on building up a complete table using VBA.
I am building a project management app and need some help with how to
I am building Rails 3 app and I need some help for my database
I'm building a custom Sharepoint 2010 activity which does some business logic, and at
I need some help on what's important and best practices when building a .NET
I am new to WPF and need some help and guidance. I am building
i need some help in building a regular expression to remove href links with

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.