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
293
votes
15 answers

Make absolute positioned div expand parent div height

As you can see in the CSS below, I want child2 to position itself before child1. This is because the site I'm currently developing should also work on mobile devices, on which the child2 should be at the bottom, as it contains the navigation which I…
user557419
156
votes
7 answers

MVC 3: How to render a view without its layout page when loaded via ajax?

I am learning about Progressive Enhancement and I have a question about AJAXifying views. In my MVC 3 project I have a layout page, a viewstart page, and two plain views. The viewstart page is in the root of the Views folder and thus applies to all…
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
86
votes
26 answers

Where does error CS0433 "Type 'X' already exists in both A.dll and B.dll " come from?

When I run a webapp from Visual Studio 2008 SP1 using the internal web server (not IIS) I receive the above mentioned error. The full error (source file Default.aspx.cs): Compiler Error Message: CS0433: The type 'WebApplication3.Site1' exists in …
Abel
  • 56,041
  • 24
  • 146
  • 247
85
votes
6 answers

how to set a default 'enter' on a certain button

There is a textbox on a ContentPage. When the user presses Enter in that textbox I am trying to fire a 'Submit' button on this ContentPage. I'd like to fire off that particular button's event. Instead, there is a search textbox & button on the top…
Ron
  • 1,901
  • 4
  • 19
  • 38
82
votes
7 answers

ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found

After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or…
Bobby Cannon
  • 6,665
  • 8
  • 33
  • 46
71
votes
13 answers

Master Page Weirdness - "Content controls have to be top-level controls in a content page or a nested master page that references a master page."

This is weird. I added a brand new Web Application project to my solution in Visual Studio 2008. Created a master page. Made zero modifications. Created a new webform. Set its master page to the MP I just created. Still, no modifications. No…
NoCarrier
  • 2,558
  • 4
  • 33
  • 44
65
votes
5 answers

active menu item - asp.net mvc3 master page

I've been scanning around trying to find an appropriate solution for assigning "active/current" class to menu items from the master page. The line is split down the middle with regards of whether to do this client vs server side. Truthfully I'm new…
Michael
  • 742
  • 1
  • 9
  • 17
61
votes
3 answers

jquery: find element whose id has a particular pattern

I am trying to find a span element who has an id in a particular pattern. Its main use is to find certain elements rendered by an asp.net (aspx) page which is derived from a master page.
deostroll
  • 11,661
  • 21
  • 90
  • 161
58
votes
7 answers

how to access master page control from content page

I have a master page which contains a label for status messages. I need to set the status text from different .aspx pages. How can this be done from the content page? public partial class Site : System.Web.UI.MasterPage { public string…
LeonidasFett
  • 3,052
  • 4
  • 46
  • 76
50
votes
4 answers

Combine ASP.Net MVC with WebForms

Is it possible to create a MVC root application (Portal with masterpages and themes) and add a couple of WebForms based subprojects (we already have an existing WebForms application that we would like to integrate into the Portal)? How would you…
Yvo
  • 18,681
  • 11
  • 71
  • 90
46
votes
3 answers

Which event called first? Master Page Page_Load or Content Page Page_Load

I have a Master page and a webpage that uses the Master page. In both I have a Page_Load event handler. In which order are the Page_Load handlers called? Content first then Master or Master first then content?
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
45
votes
11 answers

Parser Error: '_Default' is not allowed here because it does not extend class 'System.Web.UI.Page' & MasterType declaration

I recently converted a website project to a web application project in Visual Studio 2008. I finally got it to compile, and the first page (the login screen) displayed as normal, but then when it redirected to the Default.aspx page, I received an…
Amanda Kitson
  • 5,477
  • 12
  • 49
  • 73
44
votes
5 answers

Can I dynamically add HTML within a div tag from C# on load event?

Mind you, I am using master pages, but can I locate a div within the page and throw some html in there? Thanks.
Sara Chipps
  • 9,322
  • 11
  • 58
  • 103
41
votes
14 answers

Parser Error Message: Could not load type 'webmarketing'

After finishing the web application and publishing it online no matter I try I keep getting the following error, keep in mind that it runs locally as it should... Parser Error Message: Could not load type 'webmarketing'. I ran through that…
Mohammed Hanafy
  • 445
  • 1
  • 5
  • 13
40
votes
4 answers

Proper way to use JQuery when using MasterPages in ASP.NET?

I have no issues when doing using JQuery in a aspx page without a masterpage, but when I try to use it in pages that have a masterpage, it doesn't work, so I end up putting the jquery files and other script files in the page instead of the master. …
Xaisoft
  • 45,655
  • 87
  • 279
  • 432
1
2 3
99 100