Questions tagged [master-pages]

a feature of ASP.NET that allows template-based page development.

ASP.NET 2.0 introduced the concept of "master pages", which allow for template-based page development. A Web application can have one or more master pages, which, beginning with ASP.NET 2.0, can be nested. Master templates have place-holder controls, called ContentPlaceHolders to denote where the dynamic content goes, as well as HTML and JavaScript shared across child pages.

Child pages use those ContentPlaceHolder controls, which must be mapped to the place-holder of the master page that the content page is populating. The rest of the page is defined by the shared parts of the master page, much like a mail merge in a word processor. All markup and server controls in the content page must be placed within the ContentPlaceHolder control.

When a request is made for a content page, ASP.NET merges the output of the content page with the output of the master page, and sends the output to the user.

The master page remains fully accessible to the content page. This means that the content page may still manipulate headers, change title, configure caching etc. If the master page exposes public properties or methods (e.g. for setting copyright notices) the content page can use these as well.

2947 questions
24
votes
12 answers

Form Elements in ASP.NET Master Pages and Content Pages

OK, another road bump in my current project. I have never had form elements in both my master and content pages, I tend to have all the forms in the content where relevant. In the current project however, we have a page where they want both. A login…
Rob Cooper
  • 28,567
  • 26
  • 103
  • 142
22
votes
4 answers

How to resolve Cannot find ContentPlaceHolder error?

Having a "duh" moment trying to implement a new content page Here's the structure Master Page ---- Nested Master Page -------- Nested Master's Content Page Mark up: Master Page
O.O
  • 11,077
  • 18
  • 94
  • 182
20
votes
3 answers

How to get the ScriptManager of Master Page into Child page's code behind c# (.cs) file

Following is the web site environment I created: I have a Master page. I have created a Child page from it. I have placed Script Manager on the Master page. Now I want to access that Master page's Script Manager to create a User Control…
Imran Rizvi
  • 7,331
  • 11
  • 57
  • 101
20
votes
2 answers

How to create a strongly typed master page using a base controller in ASP.NET MVC

Following the NerdDinners example, I am interested in creating a strongly typed Master Page. In order to achieve this, I use a base controller which retrieves the data for the master page. All other controllers inherit this class. Similarly, I have…
darasd
  • 2,899
  • 3
  • 26
  • 39
19
votes
4 answers

How do I call a method in a Master Page from a content's code-behind page?

I have a public method in my ASP.NET Master Page. Is it possible to call this from a content page, and if so what are the steps/syntax?
Adrian S
  • 1,007
  • 4
  • 12
  • 26
19
votes
3 answers

ASP.NET MVC Master Pages

What's the difference between the ASP.NET Master Page, and the MVC Master Page? And the AJAX Master Page for that matter?
Ash
  • 24,276
  • 34
  • 107
  • 152
19
votes
8 answers

I'm new to .NET - what should I concentrate on and what should I ignore?

So, I've had a fair amount of experience programming database driven web apps using php and coldfusion (not together, at different times) and I'm starting to look into the asp.net world (I have a project coming up at work that is all asp.net/c#.) My…
Paul Mignard
  • 5,824
  • 6
  • 44
  • 60
19
votes
3 answers

Find a control on a page with a master page

I have to find a Control in an aspx page bound to a master page. The master page contains: The content page contains:
Aladdin Gallas
  • 701
  • 2
  • 12
  • 36
19
votes
2 answers

MVC Layout VS MVC Master Page

I'm starting learning MVC4. I came across the two possibilities of creating a View based on a Razor template or a Master Page. I would like to understand the practical differences between the two. For now, I can see that if I create a View using a…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
18
votes
2 answers

why we use @Master type?

if we have a master page and a content page.so the content page @Page directive look like as <%@ Page Language="C#" MasterPageFile="~/Site1.Master" .... /> so , in order to access master page controls in content page we should have to use <%@…
Usman
  • 3,200
  • 3
  • 28
  • 47
18
votes
5 answers

How to set the default button in content page using asp.net?

I need to set the content page default button. My code is like this: It is working fine, but my master page…
hmk
  • 969
  • 10
  • 38
  • 70
16
votes
11 answers

ASP.NET MVC - View with master page, how to set title?

What is prefered way of setting html title (in head) for view when using master pages? One way is by using Page.Title in .aspx file, but that requires in master page which can mess with HTML code. So, lets assume no server side controls, only pure…
bh213
  • 6,343
  • 9
  • 43
  • 52
16
votes
2 answers

How to make a certain View in MVC not inherit _Layout.cshtml?

I'm using ASP.NET MVC5, razor syntax. I need a specific "Create" view to NOT inherit the _Layout.cshtml Shared View. Basically, in this particular View, I don't want any of the _Layout.cshtml features like the navigation menu, footer, etc.
Mike Marks
  • 10,017
  • 17
  • 69
  • 128
15
votes
1 answer

ASP.NET MVC - different models for master page and view page

I have a strongly typed master page, but I want to use a different type for some of it's child pages. For example, on the master page... <%@ Master ... Inherits="System.Web.Mvc.ViewMasterPage" %> Client is already a composite…
Tony
15
votes
6 answers

Page losing title after UpdatePanel asyncpostback

I have just noticed recently that my page title will reset to the standard "Untitled Page" after I perform an asyncpostback from inside my UpdatePanel in the main page. The title will not be lost during a postback from inside the master page (such…
TheTXI
  • 37,429
  • 10
  • 86
  • 110