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
37
votes
12 answers

Only Content controls are allowed directly in a content page that contains Content controls in ASP.NET

I have an application which has a master page and child pages. My application is working fine on local host (on my intranet). But as soon as I put it on a server that is on the internet, I get the error shown below after clicking on any menus. Only…
Tripati Subudhi
  • 1,651
  • 10
  • 22
  • 26
36
votes
6 answers

how to display none through code behind

I have tried this login_div.Style("display") = "none"; But it's not working.how can I set the display of the div to none through code behind, in aspx I have a div:
Mishigen
  • 1,241
  • 6
  • 26
  • 37
34
votes
9 answers

CSS not updated during debugging ASP.NET MVC application

I am working on a test application based on ASP.NET MVC. I am new to CSS stuff so I am learning that as well. I have created a master page called "new.master" and created a new css "new.css". I am calling the view from controller as: return View…
Hemant
  • 19,486
  • 24
  • 91
  • 127
32
votes
3 answers

Is it possible to share a masterpage between MVC and webforms?

I am adding MVC to a project that has MANY legacy webform pages. This works fine. However, I currently have a separate masterpage for MVC and for the webforms. The two master pages produce essentially identical output. I'd really like to kill…
Craig Quillen
  • 2,057
  • 3
  • 23
  • 30
32
votes
4 answers

Get ControllerName and ActionName and populate the ViewData in Master Page?

I've a SuperController which will be inherited from all the controllers. In the constructor I'm trying to populate the ViewData using the ControllerName and the ActionName. I'm not going to pass the ControllerName and the ActionName as the ViewData.…
Abdulsattar Mohammed
  • 10,154
  • 13
  • 52
  • 66
30
votes
13 answers

How to use JQuery with Master Pages?

I can get simple examples to work fine as long as there's no master page involved. All I want to do is click a button and have it say "hello world" with the javascript in a .js file, using a master page. Any help very much appreciated :)
Keith Myers
  • 313
  • 1
  • 3
  • 4
28
votes
1 answer

ASP.NET MVC - Set ViewData for masterpage in base controller

I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData to be present, which displays this on every page. If I don't set this ViewData key in my controllers, I get an error that it can't find it. However, I don't want…
Razzie
  • 30,834
  • 11
  • 63
  • 78
28
votes
6 answers

Master page in HTML

Is there any way to create a similar idea as master/content page in ASP.NET in pure HTML? I want to create several pages in HTML, but I want that all of them look the same with some contents different. Is there any way to do this without creating…
mans
  • 17,104
  • 45
  • 172
  • 321
28
votes
6 answers

How to include Javascript file in Asp.Net page

I want to do some client side validation using javascript in ASP.NET page. I tried using