CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 2/12/2008 10:02:20 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 14 Views: 466 Favorited: 0 Favorite
15 Items, 1 Pages 1 |< << Go >> >|
anty.panty
Asp.Net User
PROBLEM USING MASTER PAGE IN SUBFOLDERS2/12/2008 10:02:20 AM

0

 i am having problems using masterpages in subfolders. anything in the general folder i easily link to the masterpage and it works, but when i put it in to website/folder/file.aspx it won't link properly. PLEASE HELP ME!!!!!!!!!!!!!!!!

Adam.Kahtava
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/12/2008 1:39:35 PM

0

How are you referencing your master page? Is it referenced through the web.config? Is it referenced through the .aspx page? Check that you are NOT using relative paths like "../../MasterPage", instead use the web application root operator "~/MasterPage".

A link that may be of interest: ASP.NET Web Site Paths


-Adam Kahtava [http://adam.kahtava.com]
anty.panty
Asp.Net User
Re:RE: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/14/2008 12:48:54 AM

0

 hi its me again, i am referencing ~/master.master through file.aspx but it still don't work

ylDave
Asp.Net User
Nested Master Pages on a Virtual Subdirectory - Compiler reference resolution incorrect?2/14/2008 1:21:42 AM

0

I think I may have a similar issue to the original poster. 

In IIS 5.1 I have setup a virtual directory and made one of the subfolders an application:

http://localhost/wh4l/Default.aspx

http://localhost/wh4l/SomeApp/Default.aspx

In the subfolder, I am using nested master pages; the parent does not need master pages.

I find I need to have duplicate copies of the master pages in the parent folder for the site to compile in Visual Studio 2008.

If I delete the Master pages off the parent, I get a compile error in the Default.aspx page in the subfolder referencing a master page:

Error 4 The file '/wh4l/MasterPages/SpecificLayout.master' does not exist. C:\...\WebSites\wh4l\SomeApp\Default.aspx 1 

The compiler is referencing master pages off the parent rather than the subfolder.

 

If I delete the master pages from the subfolder, the solution compiles but I get a runtime error when I access the Default.aspx page on the subfolder that is referencing the master files:

Parser Error Message: The file '/wh4l/SomeApp/MasterPages/SpecificLayout.master' does not exist.

 

The master file is being referenced from the Default.aspx on the subfolder as a relative reference:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/SpecificLayout.master" ...

 

The compiler prevents me from referencing the master pages on the parent folder:

<%@ Master Language="C#" MasterPageFile="/MasterPages/SpecificLayout.master"

Error 7 The virtual path '/MasterPages/SpecificLayout.master' maps to another application, which is not allowed. C:\...\WebSites\wh4l\SomeApp\Default.aspx 1 

It seems that IIS is resolving master page references differently than the compiler; compiler resolution of master page references appears to be incorrect.

Is there a way to change the reference or the configuration so the compiler uses the correct master pages?

 

Dave

Johnson2007
Asp.Net User
Re: Nested Master Pages on a Virtual Subdirectory - Compiler reference resolution incorrect?2/14/2008 10:20:10 AM

0

Hi,

How the files and the folders are placed in your Visual Studio 2008 and IIS? I mean do you place the masterpage in the root folder of the application(VS2008)? Is the "/MasterPages/" is the website name or a subfolder's name? In the IIS, is the masterpage placed under the vitualPage folder or in the root of your App? If you can illustrate it using a fig. it will be very grate. Thank you. 


Johnson
ylDave
Asp.Net User
Re: Nested Master Pages on a Virtual Subdirectory - Compiler reference resolution incorrect?2/14/2008 4:55:07 PM

0

Both the root folder of the application (wh4l) and a subfolder (SomeApp) are designated as applications in IIS:

C:\...\Visual Studio 2008\WebSites\wh4l\SomeApp

 I have identical sets of master pages in 2 locations; regular subdirectories off of the designated application directories:

C:\...\Visual Studio 2008\WebSites\wh4l\MasterPages

C:\...\Visual Studio 2008\WebSites\wh4l\SomeApp\MasterPages

 Thanks

happyfirst
Asp.Net User
Re: Nested Master Pages on a Virtual Subdirectory - Compiler reference resolution incorrect?2/14/2008 9:37:21 PM

0

I'm having a similar issue that I posted there: http://forums.asp.net/t/1219593.aspx

I'm using IIS and virtual directories but my sub directories are NOT IIS applications. I've got

\webapp\   [IIS virtual directory pointing to my root web application project and also an IIS Application]

\webapp\core\ [IIS virtual directory pointing to my core module web application project. NOT an IIS Application]

Now I have my default core master page templates in \webapp\core\templates project and the MasterPageFile setting is "~/Templates/Main.Master". I can open the content page in VS 2008 and it's editable. I can NOT run the application however unless I also copy Main.Master to /webapp/templates/.

So it seems at design time, VS is correctly resolving ~ relative to it's project and iis directory. At runtime, IIS is always resolving ~ to the root application.

Furthermore, at runtime, it looks like .net is trying to validate that whatever MasterPageFile is set in the aspx page is a valid existing master page. All before the PreInit event where I'm going to change that setting anyways.

Strupi
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/16/2008 5:15:30 AM

0

 Hi,

I am not sure that I understand your problem.  A common problem is when a masterpage is in the root folder and you try to use it from an aspx page in a subfolder.  In such a case, all the links on the masterpage will fail unless they are run on the server.  So they have to be converted from HTML code to server controls.  Here is how that is done.

TO FIX LINK TO STYLES IN A STYLES FOLDER
Simply add the runat="server" property to the <head> tag

Example:

<head runat="server">

<link href="styles/MyStyleSheet.css" rel="stylesheet" type="text/css" />

</head>


TO FIX IMAGES:
Use the <asp:Image tag.

Example:

<asp:image Id="Image13"  runat="server" ImageUrl="~/images/walkingholidays.jpg" alternateText="Walking Holidays" width="192" height="77" borderwidth="0" />

NOTE: Look very closly at ALL the wording.  You need the ID=, runat="server", ImageUrl =, the tilde (~) before the path and the alt property must be spelled out (AlternateText=) and border is now "borderwidth."  Any departure from this wording will screw you up. To find out more about this tag, go to the help menu in VWD and search for <asp:image in the index.

TO FIX ANCHOR TAGS:
Add an Id= property and the runat="server" property. Note that there is no tilde (~) before the path as there is in the above image example.

Example:

<a Id="A1"  href = "Pages/Calendar.aspx" runat="server">CALENDAR</a>

All of these examples assume that the MasterPage is in the root directory.

Jim Webber, Sacramento




Jim Webber, Sacramento, California
happyfirst
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 2:30:54 AM

0

This issue is NOT about a problem with the hyperlinks in the pages. They all work properly as long as they are server controls as you stated. The designer will show them in error that they don't exist though because I am including the module subdirectory in the path.

I have a web application project hosted via IIS virtual directory and application at localhost\mainsite\.

I also have a module that's ANOTHER web application project hosted as IIS virtual directory ( but NOT application ) at localhost\mainsite\core.

ALL of my user controls and pages are in core. Their hyperlinks work just fine whether I grab the master page template from locahost\mainsite\templates OR localhost\mainsite\core\templates.  If I leave the MasterPageFile setting in my core pages as ~/templates/pages/main.master then I can edit the page in the designer and VS resolves ~ to the virtual directory for the core1 directory. When I RUN the app however, .net runtime is resolving ~ to the mainsite directory so I have to have my templates ALSO in locahost\mainsite\templates or .net throws an exception about the templates missing. The problem is this is WRONG as I'm going to switch the template in PreInit but the code doesn't get that far. It's verifying the MasterPageFile setting stored in the aspx page. Personally, I think that I should be setting my MasterPageFile setting to ~/core/templates/pages/main.master in my core aspx pages. But I can't since VS resolves ~ differently than at runtime.

So I basically have to remove the MasterPageFile setting from the aspx pages so that I can truly choose where I want to load the masterpagefile from at runtime. But then I loose designer editting.

There are basically two bugs here.

1) .net should not verify that the masterpagefile exists UNTIL AFTER preinit.

2) What should '~' resolve to for a nested website application project. I think VS is doing the wrong thing. ~ should resolve to localhost\mainsite in the core project. It should not include the core directory in the path since it's not an application. If anything, VS project settings should allow us to override what ~ resolves to at designtime.

 

Strupi
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 3:17:31 AM

0

 Reply to HappyFirst:

I was responding to Anty.Panty's problem at the top of this page.  You have a different problem and need to post a new thread to get a response.  To do that, click on the Master Pages, Themes and Navigation Controls in the breadcrumb at the top of this page. That will take you to a page where you can post a new question.  Wink


Jim Webber, Sacramento, California
ylDave
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 4:59:01 AM

0

Good writeup happyfirst.  That is the same issue I'm seeing - the discrepancy between how master page file paths are getting resolved at runtime and at design time; probably a question / bug for Microsoft.  It is unclear whether it is the same issue for antsy pants since we don't have enough info on how his references are set up.  I'll post elsewhere and see if I can find an answer. 

Dave

happyfirst
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 1:27:18 PM

0

Strupi:

I was responding to Anty.Panty's problem at the top of this page.  You have a different problem and need to post a new thread to get a response.  To do that, click on the Master Pages, Themes and Navigation Controls in the breadcrumb at the top of this page. That will take you to a page where you can post a new question.  Wink

I did post another thread but nobody has replied to that and then I saw this thread where another user was describing the same problem. Here's my initial thread: http://forums.asp.net/t/1219593.aspx

happyfirst
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 1:30:52 PM

0

ylDave:
Good writeup happyfirst.  That is the same issue I'm seeing - the discrepancy between how master page file paths are getting resolved at runtime and at design time; probably a question / bug for Microsoft.  It is unclear whether it is the same issue for antsy pants since we don't have enough info on how his references are set up.  I'll post elsewhere and see if I can find an answer. 

Thanks. I hope we find a resolution besides having to leave out the MasterPageFile setting from the aspx. I initially though antsy probem was same since he referenced linking the master page and moving the master page.

Beyondard
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 4:35:41 PM

0

Strupi,

 thanks for that, I was looking on how to do that myself. however I still have trouble with linking external .js files in the head. how can I go about doing that?

currently, I have a URL variable in the web.config and I'm using  

src='<asp:Literal runat="server" text="<%$ AppSettings: URL %>"/>filename.js'
 
 to make the reference work even in sub folders. However, this can be troublesome in case someone cannot resolve the domain name of the server and is using the IP address or host name. is there a better way to do it?

 

Strupi
Asp.Net User
Re: PROBLEM USING MASTER PAGE IN SUBFOLDERS2/18/2008 5:59:10 PM

0

 Beyondard and all,

Recommend Scott Mitchel's excellent article at   http://aspnet.4guysfromrolla.com/articles/052505-1.aspx 

It appears that the Page.ResolveUrl() method he describes at the bottom of his article may be a one size fits all solution to all these problems.  I have not tried it yet.

So the solution to your problem, Beyondard, may be  

text = <%=Page.ResolveUrl("~/scripts/filename.js") %> 

or something like it. 


Jim Webber, Sacramento, California
15 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 3.5 in C# 2008: from novice to professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
Beginning ASP.NET 3.5 in VB 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 956, Published: 2007
Pro ASP.NET 2.0 in VB 2005 Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1100, Published: 2006
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1464, Published: 2006

Web:
PROBLEM USING MASTER PAGE IN SUBFOLDERS - ASP.NET Forums i am having problems using masterpages in subfolders. anything in the general folder i easily link to the masterpage and it works, ...
PROBLEM USING MASTER PAGE IN SUBFOLDERS - ASP.NET Forums I had a somewhat same problem and found a solution by using this site. http:// www.asp.net/learn/master-pages/tutorial-04-vb.aspx ...
JavaScript problem used in Master Pages and Subfolders the project clean but not able to do this until I fix the problem with JavaScript. I'm using a Master page in the project. Any suggestions? ...
Is it possible to have 1 masterpage and webpages in subfolders ... Aug 1, 2007 ... Any suggestions to solve this problem, or do I need a masterpage for all my subfolders? Question Stats. Zone: Programming ...
Master Pages :: URLs in Master Pages Introduction The Problem with ... because there is an Images subfolder relative to the root folder. .... In the Creating a Site-Wide Layout Using Master Pages tutorial we added a to ...

Sharing Objects Between Master Pages And Content Pages - ng.asp ... That property might then be used by other pages using the masterpage. ... And I want to call the object of Content Page in Master Page. .... pages and content pages · masterpages, folders and images · app_themes subfolders issues . ... problem with imageurl resulution inside a web user control ...
Problem with TreeView: TreeNodePopulate and TreeNodeExpanded not ... I wrote ASP web page which provides a file browser via TreeView. ... //Populate the tree based on the subfolders of the specified VirtualImageRoot ... the tree. ... invent my own PopulateOnDemand code using the TreeNodeExpanded event. ... request.form not works in masterpage's childpage content. ...
Body Background Image (CSS) and Themes - ng.asp-net-forum ... Is there a way I can have a background image on the page but still have the theme skin the controls? Thanks, .... Problem with CSS Background-Image in Skins - ng.asp-net-forum . ... using masterpage and subfolders ...
Error when posting back using PopupControlExtender - asp.net_ajax ... I know this doesn't directly solve your problem, but have you looked ... It works fine from there, but when I run it from a subfolder I get the 404. ... In the of the Master Page I was using there was a tag ...
Caching masterpages and use of ~/ in reference to MasterPageFile ... ... the main directory, and then point the URLs to the individual subfolders. ... I finally changed the reference to the master page in each child page from ... I'm trying to fix a problem, make changes in the masterpage code, ... Using the FindControl method on the Page reference means we won?t be ...






server error in '/' application.

store user based off windows login

runtime comexception when adding directory object

forms authentication timeout

seriously lost with how to implement security

about user login

getting user's email

help me please : loginview & usercontrol???

how do i copy users, roles, membership and so on from one web server to another?

logfile and formsauthentication....

destination url after login not working?

user access through multiple pages

file upload problem - access is denied but only to one folder

how to add dynamic content to hyperlink in the loginview control?

profile updating after new user create

authentication

logging out not ending user session properly

system.security.securityexception: request failed.

problems securing all files in a directory

securing an assembly

"how to add a login, roles and profile system" by scottgu

aspnetsqlprofileprovider setting datasource

decrypt issue!

i want to set folder level security for my different roles

httpmodule with session variables

why doesnt this code work????

using directory.getfiles on a mapped drive

create user wizard

need help to fix problem with windows authentication

web.config problem- the solution breaks my application

   
  Privacy | Contact Us
All Times Are GMT