Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get name of master page in asp.net

Posted on 2008-06-13
3
Medium Priority
?
865 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

972 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