CodeVerge.Net Beta


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

ASP.NET Web Hosting – 3 Months Free!



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: 8/18/2006 9:27:27 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 37 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
jm1234
Asp.Net User
accessing master pages from base page class8/18/2006 9:27:27 PM

0/0

Hi,

I have a couple different master pages, and I'm trying to write a base class that inherits Page to use for all my content pages.  But when I try to access a master page from my base class, I get Type "MasterPages_MasterPage1" is not defined", even though it is.

Here is my class:

Public Class WebBase

    Inherits System.Web.UI.Page

    Private _masterPage as MasterPages_MasterPage1   'this causes the error

End Class

WebBase is in my AppCode folder - is this where it should be, or outside with the other pages and codebehind files?  Also, MasterPages_MasterPage1 is defined, so I can't tell why I am getting this error.  Does anyone else have a similar issue or know how to get around this?  This is my folder hierarchy if that helps:

C:\MyProject

      - Folder:  App-Code

             - WebBase.vb

      - Folder: MasterPages

            - MasterPage1.master

                  - MasterPage1.master.vb

            - MasterPage2.master

                  - MasterPage2.master.vb

            - MasterPage3.master

                  - MasterPage3.master.vb

      - WebForm1.aspx

            -WebForm1.vb

I'm thinking part of the problem is because I don't have the master page created in the root directory of the project ..that it's in another folder within the root directory might be part of the problem.

Thanks!!

lostlander
Asp.Net User
Re: accessing master pages from base page class8/21/2006 6:53:56 AM

0/0

Hi, jm

The code under "App_code" folder is compiled before other code. So, it's not appropriate refer any elment in the page.

And, a better approach in your scenario , I'm afraid, is to create a base class which could be inheritted by all the master pages.

Also, I recommend you read this article, it's great, hope it helps:

http://www.odetocode.com/Articles/450.aspx

Regards!

2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005
C# for Programmers: Updated for C# 2.0 Authors: Paul J. Deitel, Pages: 1317, Published: 2005
Essential ASP.Net 2.0 Authors: Fritz Onion, Keith Brown, Pages: 345, Published: 2006
ASP.NET 2.0 MVP Hacks and Tips Authors: David Yack, Joe Mayo, Scott Hanselman, Fredrik Normén, Dan Wahlin, J. Ambrose Little, Jonathan Goodyear, Pages: 400, Published: 2006
Visual Basic 2005: How to Program Authors: Harvey M. Deitel, Pages: 1513, Published: 2006
Visual C# 2005: How to Program Authors: Harvey M. Deitel, Paul J. Deitel, Pages: 1591, Published: 2006

Web:
How to access the property of master page How can I access the property D from the base page class A? PS: I know how to use reflection to access control of master page C from the ...
Access property and control of master page from a customized ... base page class? Btw, I can access the server control of master page from base page class via Cast + FinndControl, ...
Master Pages: Master Your Site Design with Visual Inheritance and ... For example, one technique is to create a common Page-derived base class which .... In addition to accessing the Master Page, you can also change the Master ...
accessing master page class from app_code - ASP.NET Forums In the web app project the base class had no problem accessing the master page’s type/members but now that it’s in the website project in ...
CodeProject: Accessing Controls on Nested Master Page from Content ... Oct 30, 2007 ... Accessing Controls on Nested Master Page from Content Pages using Dynamic Polymorphism without casting to MasterPage classes; Author: Gyan ...
Orcs Goblins and .NET : Accessing Master Page Properties from a ... Jun 21, 2007 ... Just cast the Content Page’s Master as the class of the masterpage file which it uses, and then just access the value. ...
Master Pages 101: Using VB 2005 to Access Master Page ASP.NET ... End Class. With this property in place on the master page, referencing the txtDateTime textbox from the content page is done simply by accessing the ...
Master Pages - Strongly-Typed control access I can access *properties* on the Master Page in a strongly typed way, but. ..... For example, suppose we define a base master page class as ...
ASP.NET Master Pages Tips and Tricks Jun 14, 2007 ... Creating Master Page Base Classes ..... various tips and tricks that can be used with master pages such as accessing master page controls in ...
Master Page Inheritance and User Controls - Rick Strahl's Web Log -In the page using the master, add the directive @MasterType pointing to the base master class: <%@ MasterType TypeName="BlogMasterBase" %> -Access the ...

Videos:
Make learning English your hobby, Free ebook. http://www.2tion.com Download free Spoken English Training Kit. Spoken English is an urgent requirement and an essential skill set to possess in th...
Online Chinese Learning http://SpeakLearnChinese.com So you will have access all know online chinese learning , which is the natural choice when there are not start now? Th...
Charlie Rose - U.S. strategy in Iraq / Final Four preview / Abigail Pogrebin Segment 1: Guest Host James Fallows from The Atlantic Monthly talks about lessons learned in Vietnam and the U.S. Military strategy in Iraq with: L...
Opencast Project Open House at UC Berkeley http://www.opencastproject.org/ Opencast is an initiative driven by higher education institutions to empower: institutions - to make informed choic...
Charlie Rose - Frere-Jones, Pareles, Valdes, Michael, Ivory, Fiennes, Eldrege Segment 1: The year in music with four critics: Sasha Frere-Jones of The New Yorker, Jon Pareles of The New York Times, Mimi Valdes of Vibe, and Sia...
Zeitgeist 2 : Addendum - Subtitles English / French Zeitgeist: Addendum, by Peter Joseph 2008 English Subtitles ! French See ya later on thezeitgeistmovement.com You can Download Srt file here : EN:...
Charlie Rose - Garry Wills & Kevin Phillips / Lorin Maazel & James Conlon Segment 1: Guest Host Jon Meacham, Managing Editor of Newsweek with Garry Wills, Author, "What Jesus Meant" and Kevin Phillips, Author, "American Th...
Santa Monica Council Meeting Santa Monica Council Meeting
Long Beach City Council Meeting Long Beach City Council Meeting
Charlie Rose - David Margolick / Charles Peters / Steven Johnson Segment 1: David Margolick, author of "Beyond Glory: Joe Louis vs. Max Schmeling, and a World on the Brink". Segment 2: Charles Peters, Founder & ...




Search This Site:










horizontal menu control...

problem with menu items dynamically in asp.net 2.0 menu controls

can't resize contectplaceholders...

xmlsitemapprovider requires that sitemap nodes have unique urls.

asp.net to google sitemap

security trimming error

read web address from content page

can't move my javascript menu out from behind the content page

specifying path for resources

tree view in update panel

populate treeview programatically

inheritance broken w/master pages?

exception has been thrown by the target of an invocation

specifying master pages via database

i have problem with site map path and master page ?

giving css to html tables in master page.

asp.net menu orientation

tree view state

master page button vanishes on postback

can only inherit system.web.ui.masterpage in master pages? so how do i access variables in my classes

how to fill a .skin file?

javascript in masterpages

add nodes to sitemappath at runtime?

tweaking the treeview navigation control - perhaps???

menu & security

simple background-image in theme .css file not working! driving me crazy!!!!

master page control

sitemap

get rid of triangle image on menu control

need some help with searching a treeview control

  Privacy | Contact Us
All Times Are GMT