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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:58:57+00:00 2026-05-15T16:58:57+00:00

I have a masterpage file which is called Masterpage.master which works fine with all

  • 0

I have a masterpage file which is called Masterpage.master which works fine with all my aspx pages except aspx pages in which I try to instantiate stuff in the Page_Load method in the codebehind file.

The aspx file called ManageRoles.aspx looks like this –

            <%@ Page Language="C#" 
            AutoEventWireup="true" 
            CodeBehind="ManageRoles.aspx.cs" 
            Inherits="eservice.ManageRoles"
             MasterPageFile="~/MasterPage.Master"

            %>


            <asp:Content ID="Content2"  
                ContentPlaceHolderID="ContentPlaceHolder1" 
                runat="server">
                <!-- Start of roles -->
                <h3>
                    Manage Roles</h3>


                <asp:Label ID="Msg" ForeColor="maroon" runat="server" />
                <br />

                <!-- End of roles -->
                <asp:LoginView ID="LoginView2" runat="server">


                    <LoggedInTemplate>
                         <p id="backtoblog"></p>



                <!-- End of roles -->

                    </LoggedInTemplate>

                    <AnonymousTemplate>

                    </AnonymousTemplate>


                    </asp:LoginView>

            </asp:Content>

and the code-behind file called ManageRoles.aspx.cs looks like this –

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Web;
            using System.Web.UI;
            using System.Web.UI.WebControls;
            using System.Web.Security;



            namespace eservice
            {
                public partial class ManageRoles : System.Web.UI.Page
                {
                    private string[] rolesArray;
                    private string[] usersInRole;
                    MembershipUserCollection users;



                    protected void Page_Load(object sender, EventArgs e)
                    {
                        // clear the Msg label on each visit
                        Msg.Text = string.Empty;


                    }

                }
            }

The Masterpage.master file contains a content section like this –

            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

                    </asp:ContentPlaceHolder>

This is a web application project and it builds fine but throws a runtime exception when I click on the link for ManageRoles.aspx

I am getting the following exception –

System.NullReferenceException was unhandled by user code
Message=”Object reference not set to an instance of an object.”
Source=”eservice”
StackTrace:
at eservice.ManageRoles.Page_Load(Object sender, EventArgs e) in C:\Users\das.arunabh\Documents\Visual Studio 2008\Projects\ESERVICE_SOLUTION-MAIN\eservice\eservice\ManageRoles.aspx.cs:line 24
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

  • 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-15T16:58:58+00:00Added an answer on May 15, 2026 at 4:58 pm

    I don’t think Msg is a reserved word, but you might want to try renaming it. Most likely the designer didn’t create the member variable properly in your Designer.cs file. Try the following (basically, remove then readd the html for the label to get the designer to create the member variable):

    1. Cut the html code out of the editor
    2. Switch to the design view of the page
    3. Switch to the code behind
    4. Switch back to the page’s designer view
    5. Switch to source view
    6. Re-Paste the code
    7. Switch to the designer
    8. Go back to your codebehind.
    9. Save and if you’re lucky, the code should work.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master page which all my views inherit from. The issue I
I have to find the IDs of all the contentPlaceHolders in a MasterPage.
I have a MasterPage, with my Usercontrol inside a div. I can set visible=false
I have a treeview in my masterpage. When a contentpage is loaded i want
The basic idea of a masterpage is simple -- you have a block of
I have a master page, with a help link in the top menu. This
I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)
OK, Here is my problem, I have a master page with a HEAD section
I have a project where a .master page was created without a code behind
I have a view using a master page that contains some javascript that needs

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.