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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:38:41+00:00 2026-06-11T01:38:41+00:00

I have many aspx pages which inherits a base Class. base class has a

  • 0

I have many aspx pages which inherits a base Class.
base class has a method name “GetGroupID”, This method returns different data depends which page i am on, now few pages need to override this method (which is fine).

Problem:
I have user control which is placed in almost all pages, now this user control Accessess GetGroupID method from page base class, which is fine as long as i know page class name, since I have so many pages, one base class and one user control…it would be niceif I can get Page Class name from UserControl and execute the base method dynamically.

Curreny I have following code which works within UserControl

Dim c As homepage = CType(Me.Page, homepage)
Call c.getGroupID

However in above example I know the Page Class name (homepage), but lets say i am on a different page which has a classname “portal”, it would be impossible for me to keep track of so many pages.

I would like to excute the method in base class within user control, and I would like to override this method for certain pages.

please advise.

  • 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-11T01:38:42+00:00Added an answer on June 11, 2026 at 1:38 am

    You could let the base-page implement a custom interface, for example IGroupable with a method GetgroupId. Then you only have to know in the UserControl that it’s Page is IGroupable(either directly or through inheritance) and you know for sure that it has a method GetgroupId.

    Public Interface IGroupable
        Function GetGroupId() As Int32
    End Interface
    
    Class BasePage
        Inherits Page
        Implements IGroupable
        Public Overridable Function GetGroupId() As Integer Implements IGroupable.GetGroupId
            Return 1
        End Function
    End Class
    
    Class ChildPage
        Inherits BasePage
        ' default implementation of GetGroupId from base page '
    End Class
    
    Class SpecialPage
        Inherits BasePage
        ' override it here since it has a different implementation than in the base page '
        Public Overrides Function GetGroupId() As Integer
            Return 2
        End Function
    End Class
    

    You get the id in the UserControl in this way:

    Class UserControl1
        Inherits UserControl
        Dim id As Int32 = DirectCast(Me.Page, IGroupable).GetGroupId()
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just designing this application and made many .aspx files which have my
in my job (intranet)- I have an aspx page which has many Iframes (
I have an aspx website with many pages which accept user input, pull data
i have an aspx page which contains script references to many javascript and css
I have a custom control which is used on many pages. I am making
I have one view page (MyView.aspx) and many data sources to bind on this
I know an ASP.NET app can have as many aspx pages as you want
I have a partial class which returns a derived property: public partial class Consultation
Here the scenario is I have many .aspx pages if any page gives error,
I have many links in my page. For example <a href=/promotions/download/schools/australia.aspx>Australia</a> Now I want

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.