sycleTetten
New Member
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 - \[code\] <%@ 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>\[/code\]and the code-behind file called ManageRoles.aspx.cs looks like this - \[code\] 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; } } }\[/code\]The Masterpage.master file contains a content section like this - \[code\] <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>\[/code\]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: