I built an internal site for my company with asp.net. I copied the site to the server and tested every page in both firefox and ie and everything looked fine, but i noticed that i forgot to add titles to a couple pages. After adding the titles and copying the updated files to the server, my master page is no longer showing when viewed in ie. All the content is still displayed, but nothing from my master page. Firefox is displaying everything normally. I have tried recopying all the files and restarting the app pool. When i use ie to browse the site from the server everything works fine. Everything works fine when i preview the site locally with vwd2010. I have tried viewing the site from 3 different machines with ie and they all are showing the same thing. Has anyone seen anything like this before?
MasterPage
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<link rel="Stylesheet" type="text/css" href="styles/Styles.css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="page">
<div class="header">
<div class="title">
<h1>
register support
</h1>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="howto.aspx" Text="Common Problems"/>
<asp:MenuItem NavigateUrl="search.aspx" Text="Search"/>
<asp:MenuItem NavigateUrl="~/incidents.aspx" Text="Incidents" />
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server" />
</div>
</div>
<div class="bottomlinks">
[administrators]
</div>
</div>
</form>
</body>
</html>
Content Page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<div>
<asp:PlaceHolder ID="place1" runat="server" />
<asp:PlaceHolder ID="place2" runat="server" />
</div>
</asp:Content>
I am working with master pages and I would like to see what the top of your .aspx web page looks like.. for example it should look something like this
<%# Page Title="Student Registration" Language="C#" MasterPageFile="~/Site.Master"
AutoEventWireup="true" CodeBehind="StudentInfo.aspx.cs" Inherits="MRC_IDSWeb.Pages.StudentInfo" MaintainScrollPositionOnPostback="true" %>
Set the Page Title in the page Header Separately.. not in the html like you would in a .aspx page that does not utilize MasterPages hope this makes sense to you
Related
I have a master page with couple ContentPlaceHolder inside it and added some content page of this master page.
I would like to set Visible="False" on one asp:Content in some page but it's not working as I'm still able to view data of both asp:Content controls.
Why?
Master page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterBase.Master.cs" Inherits="MasterBase" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<!-- HEADER -->
<asp:ContentPlaceHolder ID="head" runat="server" />
<!-- CONTENT -->
<asp:ContentPlaceHolder ID="bodyContent" runat="server" />
<!-- FOOTER -->
...
</form>
</body>
</html>
Content Page
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" Visible="False">
<!-- Some Data -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyContent" runat="server">
<!-- Some Data -->
</asp:Content>
Try this
mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("Content1");
mpContentPlaceHolder.Visible=False;
I need to load pages asynchronously using asp.net C#.
I have a master with Two(2) hyperlink controls and One(1) ContentPlaceHolder.
I do not need page refresh or mute the page refresh to load page Async by clicking the hypelink control given on master page.
Code for Main.Master page, Home.aspx page and the products.aspx is given below.
Main.Master
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Main.master.cs" Inherits="AsyncPageLoadFromMasterLink.Main" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="navbar">
<asp:HyperLink ID="lnkHome" NavigateUrl="~/home.aspx" runat="server">Home</asp:HyperLink>
<br />
<asp:HyperLink ID="lnkProducts" NavigateUrl="~/products.aspx" runat="server">Products</asp:HyperLink>
</div>
<div id="main">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
home.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="home.aspx.cs" Inherits="AsyncPageLoadFromMasterLink.home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>This is Home Page</h1>
</asp:Content>
products.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="products.aspx.cs" Inherits="AsyncPageLoadFromMasterLink.products" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>This is Products page</h1>
</asp:Content>
Bundle of Thanks in Advance
I bet you need to add the hyperlinks to the update panel and bind the hyperlink's OnClick() event to the update panel's trigger.
This question already has answers here:
Content controls have to be top-level controls in a content page or a nested master page that references a master page
(2 answers)
Closed 6 years ago.
I have added a masterpage to my project, and now when i try to inherit this masterpage to one page, I get this error:
'Content controls have to be top-level controls in a content page or a nested master page that references a master page.'
master_page.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="master_page.master.cs"Inherits="KitchenCounter.master_pages.MasterPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
</head>
<body>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<div class="menuBar">
<ul>
<li class="hvr-bounce-to-bottom active"><a>Home</a></li>
<li class="hvr-bounce-to-bottom">Account</li>
<li class="hvr-bounce-to-bottom">Recipes</li>
<li class="hvr-bounce-to-bottom">Contact</li>
</ul>
</div>
</asp:ContentPlaceHolder>
</asp:Content>
</body>
</html>
Index.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KitchenCounter.pages.Index" MasterPageFile="~/kitchencounter/master_pages/master_page.Master"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Kitchen Counter | Home</title>
<link rel="stylesheet" href="kitchencounter/css/main.css" />
</head>
<body>
</body>
</html>
Any ideas where to start with this? Any help is appreciated.
The idea behind a master page with content pages is that your master page contains items that should appear on every (or most) page in your site, with placeholders left where a content page will fill in information specific to that page. With that premise in mind, there are a few things to change:
You put the content controls in the master page; they need to go in the content page, which in your case is Index.aspx.
Additionally, your content page should only contain as its top-level controls tags - you use the ContentPlaceHolderId attribute to match the content inside the tags on your content page to the places where the content belongs on the Master page.
Finally, your markup for your navigation bar needs to be outside of the control on your Master page. The control is just that - a placeholder; nothing goes inside of it.
So try this:
master_page.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="master_page.master.cs"Inherits="KitchenCounter.master_pages.MasterPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div class="menuBar">
<ul>
<li class="hvr-bounce-to-bottom active"><a>Home</a></li>
<li class="hvr-bounce-to-bottom">Account</li>
<li class="hvr-bounce-to-bottom">Recipes</li>
<li class="hvr-bounce-to-bottom">Contact</li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</body>
</html>
Index.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="KitchenCounter.pages.Index" MasterPageFile="~/kitchencounter/master_pages/master_page.Master"%>
<asp:Content runat="server" ContentPlaceHolderID="head">
<title>Kitchen Counter | Home</title>
<link rel="stylesheet" href="kitchencounter/css/main.css" />
</asp:Content>
<asp:Content runat="server" ContentPlaceHolderID="MainContent">
The text that is specific for your Index page goes here.
</asp:Content>
I tried the following code to the Webform.aspx page:
<asp:Button ID="btnShowAssignLecturer" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
It says: System.Web.HttpException: Control 'ctl00_head_btnShowAssignLecturer' of type 'Button' must be placed inside a form tag with runat=server.
When I do that, I get another error. Not quite sure what to do.
Master page code:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="AllsWellHospital.Front_End.MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<h1>All Wells Hospital</h1>
<p>
<asp:Label ID="DateDisplay" runat="server"></asp:Label>
</p>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
<link id="Link1" href="/Styles/StyleSheet2.css" runat="server" rel="stylesheet" type="text/css"/>
<style>
body
{
background-color:#d0e4fe;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="topContent">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="WebForm1.aspx" Text="Web form.aspx" Value="Upload SP10"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>
</body>
</html>
Webform.aspx code:
<%# Page Title="" Language="C#" MasterPageFile="~/Front_End/MasterPage.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AllsWellHospital.Front_End.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Course Report"></asp:Label>
<asp:Button ID="btnShowAssignLecturer" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
</asp:Content>
Your button needs to be within a form tag and currently it isn't. Do you really want to place the button within the head portion of your form? Why not just add another content area for your main content. Try doing something like this:
Master Page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="AllsWellHospital.Front_End.MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<h1>All Wells Hospital</h1>
<p>
<asp:Label ID="DateDisplay" runat="server"></asp:Label>
</p>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
<link id="Link1" href="/Styles/StyleSheet2.css" runat="server" rel="stylesheet" type="text/css"/>
<style>
body
{
background-color:#d0e4fe;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="topContent">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="WebForm1.aspx" Text="Web form.aspx" Value="Upload SP10"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</form>
Your aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/Front_End/MasterPage.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AllsWellHospital.Front_End.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium"
Text="Course Report"></asp:Label>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Button ID="Button1" runat="server"
onclick="btnShowAssignLecturer_Click" Text="Assign Lecturer To Room" />
</asp:Content>
A button must be placed inside of a server managed <form> tag in order for the post to actually do anything in the ASP pipeline.
However, your content place holder Content1 is inside the <head> tag of the master page, where <form> is invalid. You need to rethink your master page so that this content does not live inside of the <head> element, and include a <form runat='server'> surrounding your form.
You may have meant to use the HTML 5 <header> element, which is distintly different than the normal <head> element.
I'm new in asp.net, I am currently in the basic of master.pages.
I am testing how to put an image header to my master page.
Here's my master.master:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="master.master.cs" Inherits="master" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
And here's the Default.aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/master.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
When I run this, The imageHeader that I put in the master.master, didn't show up.
Any assistance from you guys will be greatly appreciated.
Thanks for all your help!
If you are trying to see the image in all your pages, move out image from ContentPlaceHolder in your MasterPage
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
</asp:ContentPlaceHolder>
TO :
<asp:Image ID="headerImage" runat="server" ImageUrl="~/images/cross-header.gif" />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>