473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Accessing Master Page Custom Properties in Design Mode

Is there any way to access the custom properties of a master page from the
aspx form?

I know the custom properties of a master page can be accessed from the
aspx.cs partial class by specifying the MasterType directive on the aspx form.

My master page will render a custom navigation menu and I'd like to put in
the properties of which tab and sub tab to load and other misc style info in
the aspx form that can be used by master page.

Thanks in advance,
Suresh.
Oct 21 '06 #1
4 2768
Cast the return value of Page.Master to your specific master page type and
set/get its properties.

"Suresh" <Su****@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
Is there any way to access the custom properties of a master page from the
aspx form?

I know the custom properties of a master page can be accessed from the
aspx.cs partial class by specifying the MasterType directive on the aspx
form.

My master page will render a custom navigation menu and I'd like to put in
the properties of which tab and sub tab to load and other misc style info in
the aspx form that can be used by master page.

Thanks in advance,
Suresh.

Oct 21 '06 #2
Isn't what you are saying only possible from the codebehind??

"Siva M" wrote:
Cast the return value of Page.Master to your specific master page type and
set/get its properties.

"Suresh" <Su****@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
Is there any way to access the custom properties of a master page from the
aspx form?

I know the custom properties of a master page can be accessed from the
aspx.cs partial class by specifying the MasterType directive on the aspx
form.

My master page will render a custom navigation menu and I'd like to put in
the properties of which tab and sub tab to load and other misc style info in
the aspx form that can be used by master page.

Thanks in advance,
Suresh.

Oct 21 '06 #3
Yes.

"Suresh" <Su****@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
Isn't what you are saying only possible from the codebehind??

"Siva M" wrote:
Cast the return value of Page.Master to your specific master page type and
set/get its properties.

"Suresh" <Su****@discussions.microsoft.comwrote in message
news:F8**********************************@microsof t.com...
Is there any way to access the custom properties of a master page from the
aspx form?

I know the custom properties of a master page can be accessed from the
aspx.cs partial class by specifying the MasterType directive on the aspx
form.

My master page will render a custom navigation menu and I'd like to put in
the properties of which tab and sub tab to load and other misc style info
in
the aspx form that can be used by master page.

Thanks in advance,
Suresh.

Oct 21 '06 #4
Figured it out!! (Using a different approach)

First of all there doesn't seem to be a way to specify the custom properties
of a master page in the aspx form.

But I can add custom attributes to the Page directive by using a base page
class that my web forms can inherit. I can put my custom properties in my
base page and set them on the aspx form in design mode. This is only
possible if I set the CodeFileBaseClass of Page in the aspx form to my base
page class.

Then from my master page I'm able to interrogate this properties.

However, I'm not sure if this is the best solution.

Example below:

1. BasePage

public class BasePage : System.Web.UI.Page
{
private string _Header;

public string Header
{
get { return _Header; }
set { _Header = value; }
}

public BasePage() { }
}

2. Page directive on my aspx form (Note: Header and CodeFileBaseClass
settings)

<%@ Page Language="C#" MasterPageFile="~/App_Master/Main.master"
CodeFileBaseClass="BasePage" Header="This is a Test!" AutoEventWireup="true"
CodeFile="SamplePage.aspx.cs" Inherits="App_Pages_SamplePage" Title="Sample
Page" %>

3. Master Page

public partial class App_Master_Main : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page is BasePage)
{
BasePage p = (BasePage)this.Page;
ltlFormHeader.Text = p.Header;
}
}
}

If anyone is interested in this and can actually follow what I'm doing and
realize that this is bad... Please let me know a better way.

Thanks,
Suresh.

"Suresh" wrote:
Is there any way to access the custom properties of a master page from the
aspx form?

I know the custom properties of a master page can be accessed from the
aspx.cs partial class by specifying the MasterType directive on the aspx form.

My master page will render a custom navigation menu and I'd like to put in
the properties of which tab and sub tab to load and other misc style info in
the aspx form that can be used by master page.

Thanks in advance,
Suresh.
Oct 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
4
by: Steve Franks | last post by:
I have this cool nested master page scenario working great. However what is the correct way to be able to access a strongly typed property at the top level master from a content page that has a...
14
by: multiformity | last post by:
So I have been working on an opensource project for a while, and decided to really try to make it look better after focusing on the functionality most of this time. Up to now, I have simply used a...
5
by: Electrified Research | last post by:
>From ASP.NET 1.1 I have a very useful UserControl which acts like a template control. I call it a CustomTemplate. Basically it gives me a re-usable look to sections of the site without having...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
4
by: fishek | last post by:
I have a Master Page with a property defined in codebehind like this: private string profile; public string Profile { get { return profile; } } I can set the property value in the master...
3
by: Rolf Welskes | last post by:
Hello, for a large web site project we would like to use nested Master Pages. Unfortunely VS2005 is not able to show pages in design mode when nested Master pages are used. This has the...
3
by: William Youngman | last post by:
I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.