CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/11/2006 1:39:43 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 10 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
cyad
Asp.Net User
Master Page question4/11/2006 1:39:43 PM

0/0

I have a master page in my web app that works great when the pages that use it are in the same directory. But when I have pages use it that are in a sub-directory, the links used in the master page are broken due to the fact that the directories are different.

I though one way of fixing this would be to use a directory + "filename.aspx" structure where directory is a master page property that could be modified by the pages that will reference it. Therefore if a page is in a subdirectory, it could make the value of directory = "./", or something like that.

So my question is, is there a simpler way of doing this. I'd rather not create a master page for each directory.

Thanks in advance.

MorningZ
Asp.Net User
Re: Master Page question4/11/2006 4:55:13 PM

0/0

Two choices

1) involving server controls, in which the ASP.NET runtime will replace"~" with the application root

use the "~" to prefix your href/src parameters, examples:

<img src="~/images/foo.jog" runat="server" />
<asp:Image ImageURL="~/images/foo.jpg" runat="server" />
<a href="~/manage/default.aspx" runat="server">Manage Site</a>
<asp:Hyperlink NavigateURL="~/manage/default.aspx" runat="server" />

2) Use virtual paths in non-server controls, which the leading "/" means "Start at root"

<img src="/images/foo.jpg" />
<a href="/manage/default.aspx">Manage Site</a>


Now if you go with option #2 and you are using Studio or Web Dev Express, you will run into the problem that the built in Web Server adds a level to the directory structure, but there is an easy fix for that
http://weblogs.asp.net/scottgu/archive/2005/11/21/431138.aspx

Above all, don't think of the MasterPage (.master) and the Content (.aspx) page as different entities at the end of the page's life cycle... all the code is merged together before it gets sent as HTML to the client (well, much before that stage anyways), so treating the links and references to "start at root" gives you the flexibility to put this stuff anywhere in your application


"If you make it idiot proof, they'll build a better idiot"
cyad
Asp.Net User
Re: Master Page question4/11/2006 7:02:16 PM

0/0

Thanks, that worked like a charm. I have another Master Page question. I have defined a few functions and properties in the master page. How do I access them from the code behind of the pages that use the master page? Is it the same as using any other class?

StrongTypes
Asp.Net User
Re: Master Page question4/11/2006 8:38:39 PM

0/0

cyad:
How do I access them from the code behind of the pages that use the master page? Is it the same as using any other class?

Add the following directive to the content page:

<%@ MasterType TypeName="MasterPageClassName" %>

or

<%@ MasterType VirtualPath="~/VirtualPath/Master.master" %>

Then you can cast as follows to access a property, for example:

((MasterPageClass)this.Master).PropertyName = SomeValue

HTH,
Ryan


Ryan Olshan
Microsoft MVP, ASP.NET
Blog | Group | Website | Strong Coders Community

How to ask a question
bpag
Asp.Net User
Re: Master Page question4/11/2006 8:54:30 PM

0/0

Actually the nice thing about the MasterType directive is that when you put it in your page then this.Master will give you a strongly typed master page based on the type you specify so you don't have to cast it. If you don't specify the MasterType directive than you have to cast it to your master page class.

If this post answered your question please remember to 'Mark as Answer'!
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Adobe FrameMaker 7.0: Classroom in a Book Authors: Adobe Creative Team, Adobe Systems, Adobe Creative Team, Pages: 504, Published: 2002
The Complete Works Authors: William Shakespeare, Stephen Orgel, A. R. Braunmuller, Pages: 1754, Published: 2002
Master the SAT Authors: PINE, Phil Pine, Pages: 720, Published: 2004
Adobe InDesign 2.0: Classroom in a Book Authors: Adobe Systems, Adobe Creative Team, Pages: 468, Published: 2002
The Merry Wives of Windsor Authors: William Shakespeare, Barbara A. Mowat, Paul Werstine, Folger Shakespeare Library, Pages: 320, Published: 2004
Master the LSAT Authors: Jeff Kolby, Scott Thornburg, Pages: 608, Published: 2005
O'Brien's Encyclopedia of Forms.: Master Subject Index. Authors: A H O'Brien, Honsberger, John D. (John David), Shachter, Irvin M, John David Honsberger, Arthur Henry O'Brien, John D Honsberger, O'Brien, A. H. (Arthur Henry), 1865-1957, Shachter, Irvin M, Pages: 0, Published: 1994

Web:
MasterPage in MasterPage? : microsoft, visual studio, 2005 2008, .net Simply put - is there a way to have MasterPage's within ContentPlaceHolders? Question Stats. Zone: Programming. Question Asked By: luefher ...
Microsoft TechNet SharePoint - General Question and Answers and ... You can configure it in Site Settings > Site Master Page Settings. I have a master page question. I am sorry if I am asking very stupid questions. ...
Master Pages vs. Themes: Which Do You Choose? Over the last few months I have heard a lot of confusion and question about if a site should use a master page or a theme. In this post I am going to go ...
Data Tutorial #2: Building our Master Page and Site Navigation ... I have a question regarding master pages and using PostBackURL. When was trying to use PostBackURL from page1.aspx which is a content place holder from ...
Quark: Master pages: Frequently asked questions The following answers address some of the most commonly asked questions regarding master pages in QuarkXPress® software documents, including formatting, ...
.Net Interview Questions & Answers: What is the use of Master ... Net Interview Questions & Answers ... A master page in ASP.Net provides shared HTML, controls, and code that can be used as a template for all of the pages ...
Introduction to ASP.NET Master Pages With the inception of ASP.NET 2.0 with VS.NET 2005, a lot of new features have been introduced which make it possible to increase productivity and web ...
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... Here is one question that comes up: how do we specify a control skin so that the skin only applies to controls on the master page? ...
Re: Master page question : Adobe InDesign Re: Master page question - Join the discussion of Adobe InDesign in Creative Cow's forum for users of this powerful page layout system.
Sharepoint general Re: Master Page Question Master Page Question - Don. 09-Jan-08 09:53:56. Does any know where I can find a place to obtain pre-made master pages. I have been looking around and I can ...

Videos:
Master Gardeners of Burlington County A look at a program in which volunteer master gardeners help home garden enthusiasts with their questions.
Master Debaters America's oldest humorous debating society, The Master Debaters settle humanity's weightiest questions like: "Does smoking marijuana really make you ...
How to destroy a standee Michael and John present, how to destroy a theater standee the right way. The original standee video of the internet. If anyone has any questions f...
how to make a master chief costume this is the only video on youtube showing how to fully make youre own master chief costume out of resin and fiberglass. *EDIT* http://www.tamasoft....
Jhonen Vasquez ~ Master of Puppets! Please, just watch the video. Very few people rarely look into the description boxes, because they're too damn lazy. Hell, I'm one of those people....
Depeche Mode 1981 - 2006 For the people who don't know the band Depeche Mode yet. Or for people who just want to see it. But there's nothing new here. The new album is now pl...
Backlinks to #1on Google in 48hrs http://trafficcoleman.com/google.htm backlinks links exchange traffic free visitors http://trafficcoleman.com/google.htm It is out of question that ...
Greg McMahon [CarbonCopyPRO] Top Master Marketer http://LifestyleDesignMarketing.com?t=CCPMasterMarketer Greg McMahon is a Top Earner and Leader in CarbonCopyPRO and was recently awarded with the co...
Lage Raho Munna Bhai [ hindi film ] In this sequel to the highly successful and much appreciated Munnabhai MBBS , the affable goon Murli Prasad Sharma aka Munna (Sanjay Dutt) and his tr...
Check out our "Landing Page" & More for Abunza! Visit http://abunza.mobi to see our Custom Lead Capture Page, 15 Page Website, 100K Training & More for our Team Members Only! This video also cont...




Search This Site:










textbox readonly problem

left side cascading menu

change item positioning from relative to absolute in visual web developer 2008

ssl and certficates

error about bulid a modules under dnn4.0 using c# templates

for those of you who implement forms or windows authentication..

how does your code know if you're in preview mode?

unhandled error loading module (dnn 3.0.9)

invalid formatetc structure (exception from hresult: 0x80040064(dv_e_formatetc))

dotnetnuke visual stuio 2003 iis 5.1 - opening the solution file

skinobject with database access

is there a way to make a child portal private so that it can not be accessed by simply typing in the url?

adding new textbox into create

how can i install dnn 2.1.2

debugging dnn2

huge truble with digital certificate urgent !

service asp.net restarts automatically

how to add page_init( ) handler???

viewstate persistence problem

where is the xaml designer?

shoppingcart.aspx

how to configure forms authentication.

menu item from database...in asp.net (with c# --sql)

simple question on database data editing..

cryptacquirecontext failed error

yet another working site.

dnn 3.0.9 an unhandled error has occurred

assembly version issues with our new wap projects and external modules.

how can i create report popup

bug trying to implement dotnetnuke.dk c# helloworld

 
All Times Are GMT