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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:18:40+00:00 2026-05-13T08:18:40+00:00

I have created two partial classes for a web page. Now i have given

  • 0

I have created two partial classes for a web page.

Now i have given a defination of one function say submit() that i m calling at OnSubmit event of button.

But this function is not being called, the program doesnot compiles as it is not able to search the defination of function, which was defined in another partial class. Is it possible to call this function or i have to give defination of function in same file where i m calling it

eg

<%@ Page Language="C#" MasterPageFile="~/Master Pages/LeftMenu.master" AutoEventWireup="true" CodeFile="Registration.aspx.cs" Inherits="Web_Pages_Authentication_Login_Management_Registration" Title="Registration" StylesheetTheme="Default Theme 1"  %>

Registration.aspx.cs

public partial class Web_Pages_Authentication_Login_Management_Registration : System.Web.UI.Page
{
    private string firstName;
    private string lastName;
    private string userName;
    private string userPassword;
    private string primaryEmail;
protected void btnSubmit_Click(object sender, EventArgs e)
    {
       Display();
    }
}

Registration_Database.cs

   public partial class Web_Pages_Authentication_Login_Management_Registration 
    {
       const string dbFirstName = "@FirstName";
       const string dbLastName = "@LastName";
       const string dbUserName= "@UserName";
       const string dbUserPassword = "@UserPassword";
       const string dbPrimaryEmail = "@PrimaryEmail";  

       void Display()
          {
              firstName="XYZ"; //This variable is not accessible when i put both files in different directories
          }
    }

I am getting following error

Error   1   'Web_Pages_Authentication_Login_Management_Registration' does not contain a definition for 'Display' and no extension method 'Display' accepting a first argument of type 'Web_Pages_Authentication_Login_Management_Registration' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\Online Test\Web Pages\Authentication\Login Management\Registration.aspx.cs  78  20  C:\...\Online Test\

Registration.aspx, Registration.aspx.cs, Registration_Database.cs are three files that are not in App_Code folder but belongs to one folder only out of which Registration.aspx.cs, Registration_Database.cs are partial classes and Registration.aspx is my design file.
Plz let me know if u want to know some more info about my problem

I am not using DLL Files. No precompiled code

  • 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-13T08:18:40+00:00Added an answer on May 13, 2026 at 8:18 am

    I think the problem you’re experiencing is because your website is dynamically compiled, rather than a precompiled web application.

    When the ASP.NET page is first accessed, the compiler will only look in the code behind file, and won’t search all the other .cs files for possible extra code for the same class. Thus, it will never see the implementation of display(), which in turn causes the code behind file to fail to compile.

    I would certainly not use a method like this for what you seem to want to do, but you could define a custom class that derives from System.Web.UI.Page and have your actual page derive from the new class. The class definition would have to be in App_Code for a dynamically compiled website.

    Registration.aspx.cs:

    public partial class Web_Pages_Authentication_Login_Management_Registration : MyPage
    {
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Display();
        }
    }
    

    App_Code\MyPage.cs:

    public class MyPage : System.Web.UI.Page
    {
        protected void Display()
        {
            // ...
        }
    }
    

    In any case: you certainly shouldn’t use static variables the way you are using them, this will cause problems if multiple people are using your site at the same time. Frankly, your example doesn’t make much sense to me. Maybe if we had more information about what you’re trying to accomplish, we could provide a best-practise way to do it.

    Note that in your example, putting the second file in App_Code directory will not make it work. That would simply result in two classes with the exact same class name (provided the namespaces match of course). It really doesn’t like that 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 326k
  • Answers 326k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are looking for ERD: http://en.wikipedia.org/wiki/Entity-relationship_model As for a tool,… May 14, 2026 at 1:38 am
  • Editorial Team
    Editorial Team added an answer See the following post about monitoring an Exchange mailbox with… May 14, 2026 at 1:38 am
  • Editorial Team
    Editorial Team added an answer In Flex 3.x the CSS selector ToolTip { font-size: 24;… May 14, 2026 at 1:38 am

Related Questions

While refactoring some C# classes, I've run into classes that implement IDisposable. Without thinking,
This scenario comes up often, now that I use LinkToSql and the classes it
I'm working with a 14-year old schema where a parent table (P) contains a
Weird question, but one that puzzles me a bit. In the old days when
I can display a list of all customers and I can display a list

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.