Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get name of master page in asp.net

Posted on 2008-06-13
3
Medium Priority
?
861 Views
Last Modified: 2008-06-21
asp.net  3.5 with vb

My issue seems quite simple but am having some probems.

I have a master page with a number of child pages.

When a page loads and is based on the top level master page, I want to run code in the page load event.  If a page is based on any of the child masters then I do not want to run the code.

I thought a simple bit of code as below (pseudo code) in page_load woud do the trick:

if currentpage.masterpagefile = "mypage.master" then
run code
end if

If I could get the name of the current page master file then I would be fine but am not managing to do this.

Anyone know how this can be done

Wing
0
Comment
Question by:WingYip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:skiltz
ID: 21782223
that works fine for me....

have you tried outputting the name ie response.write(me.masterpagefile.toString())

I have a masterpage called site.master and the output in my case was /site.master
0
 
LVL 1

Author Comment

by:WingYip
ID: 21782333
I realise I've put the code in the top level master page itself.  Is this not the way to do it.  I assumed taht the code would execute in the context of the content page but perhaps not.  Will I have to create a class and refer to it from all pages where I want the code executed I wonder?

Wing
0
 
LVL 1

Accepted Solution

by:
WingYip earned 0 total points
ID: 21783212
Sorted it.

I should be writing

me.page.masterpagefile

me.masterpagefile doesnt seem to work...

Am going for points refund

Cheers for input

Wing
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question