I have used Master Pages with ASP.Net for some time. I have been able to develop Master pages with header and footing content but never sucessful with side panels.
What this project needs is a Main Master page with header and footer contents. Then another master page that uses the first master page and has it's content of the left side of the remaining middle. The Detail will go to the right with the left master content about one third and the detail about two third.
A working example would be good if possible.
Thanks.
Bob
Possibly looking for nested master pages?
Site.master
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MySite.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form runat="server">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</form>
</body>
Nested.master
<%# Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Nester.master.cs" Inherits="MySite.NestedMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div style="float:left;width:200px;margin-right:5px;">
<asp:ContentPlaceHolder runat="server" ID="LeftNavigation"></asp:ContentPlaceHolder>
</div>
<div style="float:left;width:440px;margin-right:5px;>
<asp:ContentPlaceHolder runat="server" ID="MainContents"></asp:ContentPlaceHolder>
</div>
<div style="clear:both;"></div>
</asp:Content>
Default.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Nested.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MySite.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftNavigation" runat="server">
<p>Left navigation content</p>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContents" runat="server">
<p>Body content</p>
</asp:Content>
Related
I am creating an asp website using a Master page. I have some links inside the content page. I want to surf them using updatepanel, leaving the master page content intact. How do I achieve that?
Master Page
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="TestJquery.Site1" %>
<!DOCTYPE html>
<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">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
this is master
<% Response.Write(DateTime.Now); %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Default.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="TestJquery._default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
This is slave
<asp:HyperLink NavigateUrl="default2.aspx" runat="server">default.aspx</asp:HyperLink>
</asp:Content>
Default1.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="default2.aspx.cs" Inherits="TestJquery.default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
this is slave
<asp:HyperLink NavigateUrl="default.aspx" runat="server">default</asp:HyperLink>
</asp:Content>
I know there is something I am missing on this
But am unable to figure out that
I have this master page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Mains.master.cs" Inherits="Sportsstop.Mains" %>
<!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>Sports Stop</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
N there is this Child page which should merge with the above master page:
<%# Page Title="" Language="C#" MasterPageFile="~/Mains.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Sportsstop.Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" >
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
Your textbox should be in child page, inside ContentPlaceholder1. I think that the one in master page is ignored.
If you want to have TextBox in master page, it cannot be inside ContentPlaceholder
Think about placeholder as a place, where the content from child page gets injected
I have a page that uses a master page.
I disabled viewstate on the page (not the master page), and I didn't notice that the viewstate was reduced.
Curious if the masterpage setting will override it?
In my testing setting EnabledViewState = "False" will not reduce the page's view state while setting ViewStateMode="Disabled" will decrease the viewstate size
Master Page
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="ViewStateTest.master.cs" Inherits="Sample.ViewStateTest" %>
<!DOCTYPE html>
<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:ContentPlaceHolder>
</div>
</form>
Child Page
<%# Page Title="" Language="C#" MasterPageFile="~/ViewStateTest.master" AutoEventWireup="true" CodeBehind="ViewstateTestPage.aspx.cs" Inherits="Sample.ViewstateTestPage" ViewStateMode="Disabled" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:TextBox runat="server"></asp:TextBox>
</asp:Content>
I have one main masterpage and three that inherit from it; my site changes masterpages based on the state of the user (logged out, logged in without admin privileges, logged in with admin privileges) in order to change the side menu appropriately.
When I'm logged in, the master pages normaluser.master and admin.master work just fine.
When I'm logged out, loggedout.master fails to render any css from the stylesheet, turning my pretty side menu into a list of underlined blue links and removing all header styles.
MasterPage.master:
<%# 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 id="Head1" runat="server">
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-color: rgb(231, 231, 255);height:100%;margin:0px;padding:0px">
<form id="form1" runat="server">
<div style="background-color:rgb(74, 60, 140);color: rgb(247, 247, 247);height:20%">
<div style='width:7%;display:inline-block;border:none;padding:0px;padding-left:2px'>
<img src="Images/globe2.png" style="height:100px;vertical-align:middle"/>
</div>
<div style='display:inline-block;vertical-align:middle;'>
<span style='font-size:36pt;padding-left:10px;font-family:Century,inherit'> Welcome To MeetSmart: </span><span style="font-size:16pt;font-style:italic"> Your smarter meeting solution</span>
</div>
</div>
<div style="height:80%">
<div style='width:15%;height:100%;display:inline-block;text-align:center;margin-top:10px;padding:0px;'>
<asp:ContentPlaceHolder id="Menu" runat="server">
</asp:ContentPlaceHolder>
</div>
<div style='display:inline-block;margin:0px;padding-left:10px;padding-top:20px;border:2px solid purple;width:75%;height:100%;vertical-align:top'>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</body>
</html>
normaluser.master:
<%# Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="normaluser.master.cs" Inherits="normaluser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<title>
<asp:ContentPlaceHolder id="title" runat="server">
</asp:ContentPlaceHolder>
</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Menu" Runat="Server">
<div class='menuItem'> <a href="Schedule.aspx" class='menuItem'>My Schedule </a></div>
<div class='menuItem'> <a href="MyProfile.aspx" class='menuItem'>My Profile </a></div>
<div class='menuItem'> <a href="DocManagerUser.aspx" class='menuItem'>Document Center </a></div>
<div class='menuItem'> <a href="Directory.aspx" class='menuItem'>Directory</a></div>
<div class='menuItem'> <a href="Logout.aspx" class='menuItem'>Log out </a></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ContentPlaceHolder id="mainContent" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
loggedout.master:
<%# Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="LoggedOut.master.cs" Inherits="LoggedOut" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link runat="server" href="StyleSheet.css" rel="stylesheet" type="text/css" />
<title>
<asp:ContentPlaceHolder id="title" runat="server">
</asp:ContentPlaceHolder>
</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Menu" Runat="Server">
<div class='menuItem'><a href="Login.aspx" class='menuItem'>Log In </a><br /></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ContentPlaceHolder id="mainContent" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
With or without "runat=server", the stylesheet link in loggedout does nothing; adding that was one way I tried to solve it. All the master pages and the stylesheet are in the same folder.
Considering your descriptions, looks like your CSS is in a directory which is secured under authentication. In order to have the CSS and scripts to be available on Login and other un-authenticated pages, you would need to make them available beyond authentication.
To do this, you can add those CSS and scripts etc, to a directory (say Public folder on root) and use location element in web.config to provide access to everyone to these directoy. This has not compromise on your security as such.
<configuration>
<location path="Public">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
Hi:
I am new to asp.net,so I meet some problem about the master page.
I define a master page and set some css and js within it:
<%# Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" >
<title>Master page title</title>
<script xx.js></script>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td><asp:contentplaceholder id="Main" runat="server" /></td>
<td><asp:contentplaceholder id="Footer" runat="server" /></td>
</tr>
</table>
</form>
</body>
</html>
Then my child page:
<% # Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
Footer content.
</asp:content>
When I start the child page,I found the xx.js is not included in this page,what is the problem?
<head>
<script type="text/javascript" src="xx.js"></script>
</head>
This "xx.js" should be in your appl