Hi all,
I so far understand how to acces controls on a master page, but the problem I am having is accessing classes and variable that I create in the C# file of my master page. here's a snippett of two classes being declared on my master page
private User _user;
private SAI_Login _login;
I want to declare these variables on my master page so I can have access to their members throughout my application
( Is this a good Idea or the right way to do things)
now on each of my pages I want to be able to access the above classes and their members
I know This is how it is done for a Control
Menu myMenu = new Menu();
myMenu = (Menu)Master.FindControl("Menu2");
And Msdn says to create a property for the members in the MasterPage but this does not seem to work with Classes
Any advice/help would be greatly appreciated. If am am going about it all wrong please be blunt, I would rather do it right than half ***
Here is a good example of what i'm doing
My classes on the master page, classes within my namespace
private SAIWEB.User _user;
private SAIWEB.SAI_Login _login;
Here are my public properties
public User My_user
{
get{ return _user; }
//I don't think I need a set
}
public SAI_Login My_login
{
get{ return _login;}
}
Here is the Header from one of my aspx pages inheriting from this master
<%@ Page Language="C#" MasterPageFile="~/MasterPages/SAI_BasePage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login1" Title="Untitled Page" %>
And here is the code that I am using to try and access the property on my aspx page
//I declare a local instance of the type of variable or class I want
SAIWEB.User localUser = master.My_user;
The line above returns this error
Error 2 'System.Web.UI.MasterPage' does not contain a definition for 'My_user'
What am I doing Wrong???????????????
Please Help


Reply With Quote


Bookmarks