CodeVerge.Net Beta


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

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 8/9/2005 12:30:46 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 6 Views: 72 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
7 Items, 1 Pages 1 |< << Go >> >|
ShuraF
Asp.Net User
How to access MasterPage class outside of the app_code folder8/9/2005 12:30:46 PM

0/0

Hi!
VS.Net 2005 beta 2.
I create base class definition for all pages and put it to the app_code folder:
 public class PageBase : System.Web.UI.Page
 {

}
Want all pages of my site to use PageBase as a parent class.
Also i create master page Site.master with code behind in Site.master.cs
would like to map some controls and properties from the master page to PageBase, but it seems that class SiteMaster is inaccessible from thr app_code. e.g. the following code works fine on the regular page, but the class SiteMaster became inaccessible in the app_code when moving this code to PageBase
  public CustomValidator validCustom{
   get {
    return (this.Master as SiteMaster).validCustom;
   }
  }

Not sure on the right solution of this situastion.
Unfortunately vs.net doesn't allow to move site.master to the app_code folder

Tx in advance for any help


Good luck
Vimpyboy
Asp.Net User
Sv: How to access MasterPage class outside of the app_code folder8/9/2005 1:35:19 PM

0/0

You can define your own custom baseclass in web.config using this:

<pages pageBaseType="PageBase" />
Mikael S?derstr?m
BrockAllen
Asp.Net User
Re: Sv: How to access MasterPage class outside of the app_code folder8/9/2005 4:51:54 PM

0/0

 Vimpyboy wrote:
You can define your own custom baseclass in web.config using this:

<pages pageBaseType="PageBase" />


This works for pages that don't use codebehind. If they're using codebehind then in the codebehind class they need to explicitly specify their base class.

As for your problem, you need the Master to have a base class. You can specify a base class for your master. Create the class in App_Code and in your master's codebehind derive from your master base. Make sure your master base inherits from MasterPage.

The problem is that App_Code is compiled before the code for the ASPXs and their codebehinds... so if there's something in App_Code that need to use something from a page, you need to figure out how to push it into App_Code.

-Brock

DevelopMentor
http://staff.develop.com/ballen
ShuraF
Asp.Net User
Re: Sv: How to access MasterPage class outside of the app_code folder8/10/2005 5:28:04 AM

0/0

 BrockAllen wrote:

As for your problem, you need the Master to have a base class. You can specify a base class for your master. Create the class in App_Code and in your master's codebehind derive from your master base. Make sure your master base inherits from MasterPage.

The problem is that App_Code is compiled before the code for the ASPXs and their codebehinds... so if there's something in App_Code that need to use something from a page, you need to figure out how to push it into App_Code.

-Brock


y, we could create abstarct class for master page, and then implement members in the derived pages, but ....
this way seems to be a bit complex for this simple thing. Is there other way to access pages outside of app_code?
Good luck
Fredrik N
Asp.Net User
Re: Sv: How to access MasterPage class outside of the app_code folder8/10/2005 6:44:43 AM

0/0

The problem is that every pages will be compiled into its own assemblies. So that is the reason why you can't easy access code located in a page from another page or from code located in the App_Code folder.
/Fredrik Norm?n NSQUARED2
Microsoft MVP, MCSD, MCAD, MCT

Cornerstone

My Blog, ASP.Net 2.0 etc
ShuraF
Asp.Net User
Re: Sv: How to access MasterPage class outside of the app_code folder8/10/2005 7:25:12 AM

0/0

ok, so what is most flexible approach to create shared code for pages and controls in the asp.net 2.0 model?
Good luck
Fredrik N
Asp.Net User
Re: Sv: How to access MasterPage class outside of the app_code folder8/10/2005 7:46:27 AM

0/0

Shared code for pages can be added to the App_Code folder or into a separate class library.

Shared controls, like user controls or custom controls can be added as usual to the Web project.

If you want to have common members on several pages, you can create a base class that inherits the Page class and make sure all the pages that need to use it, inherits your new class.


/Fredrik Norm?n NSQUARED2
Microsoft MVP, MCSD, MCAD, MCT

Cornerstone

My Blog, ASP.Net 2.0 etc
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
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
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007
Professional C# 2005 with .NET 3.0 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1748, Published: 2007
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
Core Internet Application Development with ASP.NET 2.0 Authors: Randy Connolly, Pages: 1049, Published: 2007
Web Development, Silverlight, and ASP. NET AJAX: From Novice to Professional Authors: Laurence Moroney, Pages: 427, Published: 2008
Visual Basic 2005 Jumpstart: Pocket Guide Authors: Wei Meng Lee, Pages: 197, Published: 2005
ASP.NET 2.0 Black Book: black book Authors: Dreamtech Software, Dreamtech Software, Charul Shukla, Anil Kumar Barnwal, Dreamtech Software India, Pages: 1167, Published: 2006
ASP.NET 2.0 Everyday Apps For Dummies Authors: Doug Lowe, Pages: 504, Published: 2006

Web:
How to access MasterPage class outside of the app_code folder ... How to access MasterPage class outside of the app_code folder. Last post 08-10- 2005 3:46 AM by Fredrik N. 6 replies. Sort Posts: ...
Error when adding classes to App_Code Folder I had a web application which had couple of classes in one folder. .... App_Code complies into a diff assembly and my properties of MasterPage is in ...
Microsoft: ASP.NET - accessing master page class from app_code Code in the code folder cannot access resources outside of the folder. ... drop it in the app_code folder, the update the codefile in the masterpage markup ...
MSDN asp.net : cannot see other item out of App_Code folder I'm having the very same issue involving accessing my master page class ... But I would like to access the class in the root folder from app_code folder. ...
Cannot Access a Custom Page/MasterPage Type from a Class File ... When I was trying to access a custom Page or MasterPage type from .... outside App_Code folder, for example a MasterPage or Page class that ...
How do I access MasterPage functionality from an App_Code class? I am trying to access a label located in a MasterPage from a class located in my application's App_Code folder. The problem seems to be ...
Master Pages - Strongly-Typed control access public variable to expose a Label control on the master page): #put in App_code folder =================== public class BaseMasterPage : ...
ASP.NET Master Pages Tips and Tricks Jun 14, 2007 ... This class can be added in the App_Code folder. public abstract class BaseMasterPage : MasterPage { public abstract Label HeaderLabel ...
SitePoint » MasterPages hate logic. Throw Interfaces at Them. Aug 31, 2006 ... Now back to App_Code for the master page base class: .... I right click my web project I don’t have the option to add an App_code folder. ...
Lines of Communication First, define an event in your MasterPage class: ... place to put it is in a file named “FooEventArgs.vb” in the App_Code folder of your Web application: ...




Search This Site:










the file web.sitemap required by xmlsitemapprovider does not exist.

contentplaceholder1 won't let me rename any contorls inside it

howto control menu items max display level per parent item basis

can one make a custom dynamic adapter/provider for page access?

sub menu not visible in ie

i have a master page with title on it. how ever how d o i set the titkle for the pages that inherit from it?

locking master page.

how can i add the user control to treeview nodes

background-image not rendering (masterpage, modalpopupextender)

sitemap links open in a new window

another question about treeview

client callback & master pages

synchronize design view with skins

staticselectedstyle for a menu control

menu

populating a .net treeview control from a parent-child relationship db table

problem with repeater and sitemap

xmlsitemapprovider - troubleshooting

the asp menu control does not navigate to the navigateurl property set in the menu item

dynamic height while using a masterpage

login control in master page

multi row, multi level horizontal menu?

how to place javascript datepicker in asp:content tag

using themes - how to.

treeview clientside serching

problems with "renaming" contentplaceholder control

treeview server control

menu item text below imageurl.

howto insert controls from content to the end of contentplaceholder (without erasing it's own content)

can theme be related to different css file in different conditions?

  Privacy | Contact Us
All Times Are GMT