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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:07:33+00:00 2026-06-01T04:07:33+00:00

I am trying to access a function placed in master page code-behind from another

  • 0

I am trying to access a function placed in master page code-behind from another ASPX page as follows.

Main.master.cs:

public partial class Main : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
      ...
    }

    public static bool test()
    {
        return true;
    }
}

Product.aspx:

<%@ Page Language="C#" MasterPageFile="~/Main.master" EnableEventValidation="false"
AutoEventWireup="true" ValidateRequest="false" CodeFile="Product.aspx.cs" Inherits="Common_Product" Title="Product" %>
...
<asp:Label id="test123" runat="server" />

Product.aspx.cs:

using SiteABC.Accelerate;
public partial class Common_Product : SiteABC.Accelerate.SerializePageViewState   
{
    private void Page_Load(Object sender, EventArgs e)
    {
        Main cm = (Main)Page.Master; 
        test123.Text = "yo | " + cm.test();
    }
}

This results in a compiler error:

Compiler Error Message: CS0176: Member 'Main.test()' cannot be accessed with an instance reference; qualify it with a type name instead

What is wrong in this scenario?

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-06-01T04:07:34+00:00Added an answer on June 1, 2026 at 4:07 am

    Try this:

    public partial class Main : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        ...
    
        }
    
        public bool test()
        {
            return true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access a field of a constructor from a nested function. Here
I'm trying to access the mime.types file from a model in codeIgniter. function get_mime_type($filename,
Trying to access a Servlet from a button on HTML page //Html Page FORM
I'm trying to access a form's recordset clone from a called function which we're
I'm trying to access the post target action in a jquery function. example: <form
I am trying to access the nsstring data out side the function and also
I am trying to create a function that will block access to some of
Im trying to access a web service from a remote computer. I managed to
Im trying to access the Magento customer session in another part of my website.
I'm trying to execute a function from RAM on a Cortex-M3 processor (STM32). The

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.