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: 3/21/2006 5:27:51 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 26 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
TJakobsen
Asp.Net User
Interact with masterpage code from content page.3/21/2006 5:27:51 PM

0/0

I got a problem here when I'm trying to interact with the code behind my masterpage from a content page.

On my masterpage I got:

public partial class Site : System.Web.UI.MasterPage
{
    public bool ShowNavigationControls
    {
        set
        {
            menu1.Visible = value;
        }
        get
        {
            return menu1.Visible;
        }
    }
}

On my content page I got this:

public partial class Forside : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        myMasterPage myMaster = (myMasterPage)this.Master;
    }
}

When I try to run this, I get the following error:

"Compiler Error Message: CS0246:
The type or namespace name 'myMasterPage' could not be found (are you
missing a using directive or an assembly reference?)"

I'm pretty new to asp.net and I've seen this example in a book, but it won't work on my machine.
Any suggestions?

Thanks.
StrongTypes
Asp.Net User
Re: Interact with masterpage code from content page.3/21/2006 5:47:55 PM

0/0

Add the following directive to the content page and then it should work. You'll just need to cast to the class name of the master page, which in your case is Site.

<%@ MasterType TypeName="Site" %>

HTH,
Ryan


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

How to ask a question
TJakobsen
Asp.Net User
Re: Interact with masterpage code from content page.3/21/2006 7:28:33 PM

0/0

Thanks alot. Got it working now.
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
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 9.0: From Novice to Professional Authors: Matthew MacDonald, Pages: 1149, Published: 2007
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
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
Mastering Web Development with Microsoft Visual Studio 2005 Authors: John Paul Mueller, Pages: 822, Published: 2005
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005

Web:
Master Pages :: Programmatic Interaction Between a Content Page ... Perhaps the most common example of content and master page interaction ..... page's code-behind class name is MasterPage. This can lead to ambiguous code ...
ASP.NET Library - Articles - Access Master Page controls from the ... Load ' Set the value of the Master Page's Label to the Content Page's ... on this code and apply it to similar situations where you need the interaction ...
Less Than Dot - Wiki - ASP.NET: Access Master Page controls from ... This article shows you a simple example of how to interact with controls on the Master Page, and will give you the necessary logic to build on this code and ...
Master Page / Content Page interaction question Talk about Master Page / Content Page interaction question. ... I am not receiving the event (see code below). Is there a better way ...
Changing a content pages CCS from code in the master page? - ASP ... Is there a way to do this by putting the code in the master page for ... and check the parts of "Content Page to Master Page Interaction" ...
Safari Books Online - 9780980285819 - The ASP.NET 2.0 Anthology As a bonus, all book buyers get download access to the code archive which has all the ... How can I have my master page interact with my content page ? ...
CodeProject: Inside Master Pages. Free source code and programming ... Now you are free to add any controls or code to your master page. ... How to interact with master page controls from content page ...
Form Elements in ASP.NET Master Pages and Content Pages - Stack ... If you need the page to interact with the master page, you can access it via the Page.Master property. To interact with any publicly-visible code (methods, ...
master page interaction - JavaScript / DHTML / AJAX 2. i need to interact with the master page from within the content page so that i can set the button leading to this page to a certain color ...
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps Apr 11, 2006 ... Now it’s time to have the master page and content page interact. .... The master page sounds like a good place to put logic and code that ...




Search This Site:










unhandled exception error with blog module

arraylist help

can somebody explain these codes for me?

fedex, ups, usps, etc

expand active node in treeview control on page load

sqldatasource in .net 2.0

tab order question

how to ???

including asp files in asp.net projects

announcement module?

help -server code won't run

design view not working in vs2008

3.0.13 upgraded then host login nets critical error..input string..not in..correct format

questions about intranet and full software lifecycle

asp .net menu - web matrix

problem with submit

when i replace boundfiled with templatefield insert value is not picked up

call a javascript

multilanguage website

help regarding date for 1 year back

repeater adapter?

event calendar control

how to rename a text file

child portals in dnn 4.0.2

masterpage url

character codes

general treeview product question

cannot use variable both within and outside a method

menu, from right to left?

getting a map and driving directions on a website

 
All Times Are GMT