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: 2/28/2008 11:55:51 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 16 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
PsiStorm
Asp.Net User
Master Page common code not available in client page2/28/2008 11:55:51 AM

0/0

Hi there,

I am primarily a thick client developer but have recently started moving over to ASP.Net based development.  I need a little guidance please.  I have a the following:

Master Page

Client Page

Class Page

 

I use the class page to hold all my global vars like db connection properties, versioning properties, reusable code like DBOpen, DBClose, SQLExecute, etc.  I access the class from the master page and set all the variables.  How do I now make that class transparently available to my client page please? I first started with it being in my client page but wan't to move it now to the master page so I don't have multiple instances of the same code lying around.

 

Many thanks!

ecbruck
Asp.Net User
Re: Master Page common code not available in client page2/28/2008 1:10:45 PM

0/0

This is not a good idea. A MasterPage is simply a glorified UserControl. Therefore, you don't want to stick any common code here. Instead, if you need common code that is accessible by all of your pages including your MasterPage, then create a custom Base class for your ASPX code-behind pages.

http://aspnet.4guysfromrolla.com/articles/041305-1.aspx


Thanks, Ed

Microsoft MVP - ASP/ASP.NET

Please remember to 'Mark as Answer' if this post answered your question!
PsiStorm
Asp.Net User
Re: Master Page common code not available in client page2/28/2008 2:10:19 PM

0/0

Great, thanks for this info, not really sure I understand though. The use of a Masterpage is to have a generic template across all pages right? I understand the custom base class and will go that route if that's what I'm supposed to do, I'd just like to know that age old irritating question of "why".

Then just on top of that, would I be using the custom base class for replacing the common code in both my Master Page and Common Code Class or just my Master Page?

ecbruck
Asp.Net User
Re: Master Page common code not available in client page2/28/2008 2:48:37 PM

0/0

Like I said before, the MasterPage is basically just a UserControl and should not be used to place common code in. They're great for your UI, but I would never put anything common in it. Your ASPX base class can contain any common code for all of your ASPX pages. Your MasterPage can have access to this base class as well through use of the Control.Page property by simply casting this reference to your base class type.


Thanks, Ed

Microsoft MVP - ASP/ASP.NET

Please remember to 'Mark as Answer' if this post answered your question!
PsiStorm
Asp.Net User
Re: Master Page common code not available in client page2/29/2008 8:25:07 AM

0/0

Thanks for the advice, appreciate it!

5 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
Microsoft Office SharePoint Server 2007: The Complete Reference Authors: David Matthew Sterling, David Sterling, Pages: 788, Published: 2007
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
Pro ASP.NET for SQL Server: High Performance Data Access for Web Developers Authors: Brennan Stehling, Pages: 408, Published: 2007
Professional Community Server Authors: Wyatt Preul, Keyvan Nayyeri, Jose Lema, Jim Martin, Pages: 311, Published: 2007
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
Microsoft Sharepoint: Building Office 2007 Solutions in C# 2005 Authors: Scot Hillier, Pages: 513, Published: 2007
Production for Graphic Designers Authors: Alan Pipes, Pages: 256, Published: 2002

Web:
Master Pages: Master Your Site Design with Visual Inheritance and ... For example, one technique is to create a common Page-derived base class which .... specifying a common Master Page, as shown in the following code snippet: ...
CodeProject: Masterpage and Javascript document.getElementById ... Whenever a control is inside a page having Masterpage the client id of the ... We can make these codes as part of a common class for all the UI pages like ...
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... The master page contains some common elements, like a head tag. ...... does not provide the rebasing feature, you can compute a client side ...
ASP.NET - Wikipedia, the free encyclopedia The master page remains fully accessible to the content page. .... The generated HTML and JavaScript sent to the client browser would not always validate ...
Scheduler list fetch failed - Unofficial BOINC Wiki This Message means that the BOINC Client Software was not able to start a communication .... Obsolete: Couldn't start master page download: '(error-code)' ...
How to develop a master page that can support Firefox? - ASP.NET ... Realize that master pages is nothing, absolutely nothing, but a way to include common code (in the end, HTML) to your users' browsers. ...
Piyush Shah's Blog : Sharing Master Pages amongst Applications by ... First, I will create the Master page (and its code behind) and embed it as a Resource ..... Unfortunately that will not be available with this approach. ...
CodeProject: An Extensible Master-Page Framework for ASP.NET 1.1 ... Now, our model would have a Master Page that in turn is composed of ..... By changing the code this way, you are not limited to the placeholders which are ...
How to Create a SharePoint Server 2007 Custom Master Page and Page ... The following code example shows a custom master page. ... the page, you add it to the site collection where it is made available with other master pages. ...
Web Client Software Factory - Home Creating Page View, User Control Views and Master Pages that implement MVP and ... the source code for the Composite Web Client Automation Guidance package. ...

Videos:
A New Way to look at Networking Google Tech Talks August 30, 2006 Van Jacobson is a Research Fellow at PARC. Prior to that he was Chief Scientist and co-founder of Packet Design. P...




Search This Site:










inefficient themes applied by css: web part zones

how can i update the email field in the aspnet_membership

rowstyle-cssclass="rowstyle"

upgrade pain

visual studio 2005

treeview display

smart tags won't open and some intellisense won't fully work after installing linq ctp

i have a problem with authorization on a com+ proxy.

side menu w/ contentplaceholder as target

help with the dnn forums

how we can configure the asp application using (windows integrated authenticated) method when iis 6.0 and sql 2000 server on are on separate machines with a trusted connection ?

themes and masterpages

treeview

multiple portals, separate databases, same users, one log in ?? possible?

database diagram (e/r) for dotnetnuke 1.0.9

form security and controlling access to files

when is the new user available?

build enterprise library in vs2005 beta2 got an error

sos what is my problem ?!

how to use .asp file from .aspx file ?

about the form authentication error:resource can not be found

help. role security advice?

compilation error->bc30456: 'calendar1_dayrender' is not a member of 'asp.calendario_aspx'

server error in '/clubsite' application.

updating host settings fails after upgrading to dnn3.1.0

.net remoting security permission

news articles 00.00.04

dropdownlists &amp; databases

creating dnn 3.0 skin how to available?

? dnn + sql server howto?

 
All Times Are GMT