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
15
votes
1 answer

How to pass viewmodel to a layout/master page?

Having googling for some time, I'm a little bit confused with how to do this in asp mvc 3. So, the task is to have a common layout (or master?) page for several controllers' views. All the views are strongly-typed themselves... This layout page in…
horgh
  • 17,918
  • 22
  • 68
  • 123
15
votes
5 answers

How to control elements on a asp.net master page from child page

I have a few pages on my asp.net website that I would like to turn off a control on the master page. Is there a way to communicate with the master page from a child page?
Lloyd
  • 1,395
  • 6
  • 20
  • 37
14
votes
2 answers

Are there nested master pages in ASP.NET MVC?

I wanted to know if the MVC framework can leverage the Nested Master Page? If so does anyone have some info on how to achive this?
OneSmartGuy
  • 2,849
  • 4
  • 25
  • 24
14
votes
5 answers

Twitter bootstrap + asp.net masterpages, how to set navbar item as active when user selects it?

We are in se same situation as question Make Twitter Bootstrap navbar link active, but in our case we are using ASP.net and MasterPages... The thing is the navbar is defined at the masterpage and when you click a menuitem you are redirected to the…
VSP
  • 2,367
  • 8
  • 38
  • 59
13
votes
4 answers

How to reference a Master Page from a user control?

I'm looking for a way to (preferably) strongly type a master page from a user control which is found in a content page that uses the master page. Sadly, you can't use this in a user control: <%@ MasterType VirtualPath="~/Masters/Whatever.master"…
Bryan Denny
  • 27,363
  • 32
  • 109
  • 125
13
votes
2 answers

ASP.net access a master page variable through content page

I have a master page: <%@ Master Language="C#" AutoEventWireup="true" Codefile="AdminMaster.master.cs" Inherits="AlphaPackSite.MasterPages.AdminMaster" %> Then I have a public variable: public partial class AdminMaster : System.Web.UI.MasterPage { …
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
13
votes
2 answers

Change the master page from code behind

I have a web page named MyPage.aspx and two master page named Home.master and BlanK.master. By default MyPage.aspx uses Home.master.But based on some condition I need to change the master page from Home.aspx to Blank.master.So, how to do this from…
ANP
  • 15,287
  • 22
  • 58
  • 79
13
votes
2 answers

Open source Asp.Net Master page Templates

Where can I download Open source Asp.Net Master page Templates?
Ikram
  • 139
  • 1
  • 1
  • 3
13
votes
10 answers

How to set navbar item as active when user selects it?

I am a new ASP.NET Web Forms developer and trying to use Twitter Bootstrap with the Master Page. I am struggling with setting navbar item as active when user selects it. I created my simple master page by following this tutorial about how to use…
Android FanBoy
  • 185
  • 1
  • 4
  • 10
12
votes
2 answers

Access asp:content from code behind

Ok, I am an experienced web developer but sometimes ASP.Net is tricking me. I have a master page in asp.net. Then I have a page based on that master page (home.aspx). Now in home.aspx.cs I want to access the asp:content controls to add controls…
newtogit
  • 357
  • 3
  • 4
  • 13
12
votes
4 answers

Error: Unable to evaluate expression because the code is optimized

I am getting an error in my asp.net app that reads "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." protected void btnCustomerProfile_Click(object sender, EventArgs e) { try { …
DNR
  • 3,706
  • 14
  • 56
  • 91
11
votes
4 answers

How do I progressively render a header before content in ASP.NET master pages?

I have a large slow ASP.net site that uses master pages. I've identified that the user will have a better experience if they can see the header and navigation while the rest of the page is being generated/processed/loaded from the database. I've…
Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
11
votes
4 answers

How to run jquery script if html page is the home page...?

I'm working with an external team with our website and they recently added one of my scripts to the .NET MasterPage of the site... well it did finally get my script running but now... it loads Banners on 'every' page on the site. How can I write an…
chrisb
  • 165
  • 1
  • 1
  • 11
11
votes
4 answers

Is there anything like MasterPages on CodeIgniter Framework?

I am new to Code Igniter and I wish to know if there is anything that works like MasterPages do on .NET. Also i was wondering where should i keep my public files, like scripts, styles and images. Greetings, and Thank you in Advance
Germán Rodríguez
  • 4,284
  • 1
  • 19
  • 19
11
votes
2 answers

ASP.NET Custom Error Page for Web App that uses a Master Page

Reference KB306355: How to create custom error reporting pages in ASP.NET by using Visual C# .NET I understand how to create a Custom Errors page. There are many examples of how to do it, like in the link above. None of the examples I have found…
user153923