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 5840291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:43:15+00:00 2026-05-22T11:43:15+00:00

I am attempting to set a System.Web.UI.Control object’s ID field. The control implements an

  • 0

I am attempting to set a System.Web.UI.Control object’s ID field. The control implements an interface, IChartControl, which does not have an ID property. I would like to retrieve the control as an IChartControl and set its ID field.

Should I do this?:

IChartControl chartControl = foo.GetChartControl();
(chartControl as Control).ID = foo.GetID();
chartControl.Bar();

or would it be equally right to add a new property to IChartControl named ‘ID’ so that when I set the ID field it sets Control’s ID field.

  • 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-22T11:43:16+00:00Added an answer on May 22, 2026 at 11:43 am

    You do need to cast the object to the type that has the member you want to set, as you have in your code example.

    Adding an ID property to IChartControl will work, but only do it if it makes sense in the context of this interface. This will indeed allow you to set the ID property without needed the cast.

    So long as the ID in the interface and in Control are the same ones, you should be fine. Where you can get into trouble is if you try and use explicit interface implementations.

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

Sidebar

Related Questions

I am attempting to set a value in a textarea field using jquery with
I have a Perl script that I'm attempting to set up using Perl Threads
I have set up ASP.Net health monitoring in web.config: <healthMonitoring enabled=true> <providers> <clear />
I am attempting to set an asp.net textbox to a SQL 2005 money data
I'm attempting to set up a symbol proxy using symproxy.dll from Debugging Tools for
Hopefully some Custom Control Designers/Builders can help I'm attempting to build my first custom
I've set up an activex control to run on a webpage. The server is
I am attempting to write an ASP.net web service that will be utilized by
I'm attempting to unit test some code using NUnit. I have a method: public
I am using windbg with xp embedded. Attempting to fetch the operating system symbols

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.