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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:51:14+00:00 2026-05-15T21:51:14+00:00

I have a ASP.Net project that is setup in such a way that it

  • 0

I have a ASP.Net project that is setup in such a way that it can be dropped into any site and “just work.” All the paths are relative to the current file, not relative to the “~”. The paths are determined by ThePath = this.TemplateSourceDirectory;

This is working for everything expect registering a custom control that is created and added to one of the pages. I can add the control just fine with the Page.LoadControl but I cant cast it as the correct type to access anything.

How can I add a reference to the class from within the code itself?

  • 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-15T21:51:15+00:00Added an answer on May 15, 2026 at 9:51 pm

    If you don’t know the control’s specific type ahead of time, this isn’t possible. The class must derive from UserControl, so you can cast it to a UserControl and you’ll have access to all the methods and properties on that class. If there’s some special information or functionality you need to require all controls to have, and you need to be able to assume those are always present, then you will have to write your own class that derives from UserControl, and require all custom controls to derive from that instead:

    //all custom controls must inherit from this
    public abstract class SpecialControlBase : UserControl
    {
        public abstract void DoSomethingSpecial();
    }
    

    Then you could cast all controls at load-time to this SpecialControlBase, and have access to the DoSomethingSpecial method.

    But as far as the most-specific members of a class loaded at runtime, think about it – if I write my own control called RexsUserControl and drop it into your application, there’s no way you could know what methods and fields I’ve put on my control, so you can’t write any code that references those members specifically.

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

Sidebar

Related Questions

I have a ASP.NET MVC2 project in VS2010 that can be deployed in two
I have the following setup: ASP.net 3.5 Web Site Project C# Class Library with
I have a really simple ASP.NET web application and a web setup project that
I have an ASP.NET project that contains many classes. I am thinking about creating
I have accumulated an ASP.NET project that was running everything off of one page
We have an ASP.Net MVC project that will start with a single web server
I have an Asp.net MVC project that modestly uses jQuery scripts. My views also
Background : I have a asp.net webapplication project that should contain a public and
I have an ASP.NET VB.NET web project that references a VB.NET class library. I
I have an ASP.Net project using AJAX that I am putting on a server

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.