Solved

Get name of master page in asp.net

Posted on 2008-06-13
3
836 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now