By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,742 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,742 IT Pros & Developers. It's quick & easy.

Two question about Master Page

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Thanks a lot!

Nov 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.