Solved

Get name of master page in asp.net

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with C#, MVC, razor. 6 34
How to have a gridview column with multiple items in a column row. 2 22
ASP.net show message while code is running 3 17
Regex validation 2 24
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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

11 Experts available now in Live!

Get 1:1 Help Now