473,398 Members | 2,212 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,398 software developers and data experts.

Two question about Master Page

I have two questions about the use of Master Page:

1. How to access properties and controls in the master page from
content page? (I know I can use the "FindControl()" method of the
"Master" Property to access the controls. But how can I access the
properties? I've tried to write a property in the master page and
access it from content page, but it didn't work.)

2. How to specify default content in the master page? (I've tried to
write something directly in the "ContentPlaceHolder" of the master
page. But I can't see it through running the content page, why?)

Thanks for your answer and discussion!

Oct 31 '07 #1
4 1476
1. How to access properties and controls in the master page from
content page?
To access properties you use the Page.Master property. Page.Master returns
the Master Page as a MasterPage object. To access the members of your
inherited MasterPage you need to cast it to the proper type. You can do so
by adding a MasterType directive to the top of your content page.

<%@ MasterType virtualpath="~/Main.master" %>
2. How to specify default content in the master page? (I've tried to
write something directly in the "ContentPlaceHolder" of the master
page. But I can't see it through running the content page, why?)
By default Content Pages automatically define custom content for the
Content sections. If you want it to use the default content then you can
right-click on the Content Panel and select "Default to Master's Content"

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"lichaoir" <li******@gmail.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...
>I have two questions about the use of Master Page:

1. How to access properties and controls in the master page from
content page? (I know I can use the "FindControl()" method of the
"Master" Property to access the controls. But how can I access the
properties? I've tried to write a property in the master page and
access it from content page, but it didn't work.)

2. How to specify default content in the master page? (I've tried to
write something directly in the "ContentPlaceHolder" of the master
page. But I can't see it through running the content page, why?)

Thanks for your answer and discussion!
Oct 31 '07 #2
Thanks for your answer!
If I put something as the default content in the master page and then
put some other things in the content page, can I see both of the
content?

Oct 31 '07 #3
No. The master page has no idea what kind of stuff your going to put in the
Content Pages, thus it has no way to properly merge it with it's default
content. For example you may just put some text while another person may have
nothing except an imbedded flash animation.

However, you can add more than one content place holder on your master page.
Put the default content in one of the place holders and leave the other free
for the Content Page's content.

--
Andrew Faust
http://www.andrewfaust.com
"lichaoir" wrote:
Thanks for your answer!
If I put something as the default content in the master page and then
put some other things in the content page, can I see both of the
content?

Oct 31 '07 #4
Thanks a lot!

Nov 1 '07 #5

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

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
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...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
6
by: Sam Carleton | last post by:
Ok, over the years I have read about doing web programing and I have done some real basic stuff. Now I am digging into some real ASP.Net 2.0 and am totally lost some things. I have a master...
7
by: Just Me | last post by:
Hi I have a master page with a control on it, but I need to set a property of that control from the content. my master page is called Admin.Master and the class is Admin. I have tried this
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.