Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2012, 03:59 PM
Authorized User
 
Join Date: Apr 2012
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Armaan
Default Master Page

Master Page

Code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPage_Frontend" %>

<!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 href="../Styles/Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
  <div id="PageWrapper">
    <div id="Header"><a href = "~/" runat="server">Header goes here</a></div>
    <div id="MenuWrapper">Menu Goes Here</div>
   <div id="MainContent">
    <asp:ContentPlaceHolder ID="cpMainContent" runat="server">
    </asp:ContentPlaceHolder>
    <div id="Sidebar">Sidebar Goes Here</div>
    <div id="Footer">Footer Goes Here</div>
  </div>
  </form>
</body>
</html>
Css file
Code:
#Header
{
  background-color: #C0C0C0;
  width: 844px;
  height: 86px;
}

*
{
  font-family: Arial;
}

h1
{
  font-size: 20px;
}

.Introduction
{
  font-style: italic;
  color: #003399;
}

#PageWrapper
{
  width: 844px;
}

#MenuWrapper
{
  width: 844px;
}

#MainContent
{
  width: 664px;
  float: left;
}

#Sidebar
{
  background-color: Gray;
  width: 180px;
  float: left;
}

#Footer
{
  background-color: #C0C0C0;
  width: 844px;
  clear: both;
}

#MainContent a
{
  color: #008000;
  text-decoration: underline;
}

#MainContent a:visited
{
  color: #FF0000;
  text-decoration: underline;
}

#MainContent a:hover
{
  color: #FFA500;
  text-decoration: underline;
}

h1
{
  padding: 0px;
  margin: 0px 0px 10px 0px;
}
Sir this is the code of my css file and master page.Now please tell me why my sidebar does not aligned on right and it comes above the footer?

Thanks
 
Old April 21st, 2012, 04:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Your MainContent div is missing its closing </div> tag.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 14th, 2012, 05:50 PM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Almost the same problem

My MainContent has the closing div. My sidebar behaves the same as the origional poster's in design view, but displays correctly when i view it in the browser. Any idea why? thanks!
 
Old May 15th, 2012, 02:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you post the code for the master page? Also, is your CSS file stored in the correct folder and does it contain the proper CSS code?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 15th, 2012, 09:20 AM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

The Style sheet is in the Styles filder. I believe the page is finding it, as the formatting is applied in the browser and (for the most part) in design view.

thanks. s.

Code:
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="../Styles/Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
        <div id="PageWrapper">
            <div id="Header"><a href="~/" runat="server">Header goes Here</a>="</div>
            <div id="MenuWrapper">Menu Goes Here</div>
            <div id="Maincontent">
                <asp:ContentPlaceHolder id="cpMainContent" runat="server">
                </asp:ContentPlaceHolder>
            </div>
            <div id="Sidebar">Sidebar Goes Here</div>
            <div id="footer">Footer Goes Here</div>
        </div>
    </form>
</body>
Code:
#Header
{
    background-color: #C0C0C0;
    width: 844px;
    height: 86px;
}

*
{
    font-family: Arial;
}

h1
{
    font-size: 20px;
}

.Introduction
{
    font-style: italic;
    color: #003399;
}

#PageWrapper
{
    width: 844px;
}

#MenuWrapper
{
    width: 844px;
}


#MainContent
{
    width: 664px;
    float: Left;
}

#Sidebar
{
    background-color: #808080;
    width: 180px;
    float: Left;
}

#Footer
{
    background-color: #C0C0C0;
    width: 844px;
    clear: both;
}

#MainContent a
{
    color: #008000;
    text-decoration: underline;
}

#MainContent a:visited
{
    color: #FF0000;
    text-decoration: underline;
}
#MainContent a:hover
{
    color: #FFA500;
    text-decoration: underline;
}

h1
{
    margin: 0px 0px 10px 0px;
    padding: 0px;
}
 
Old May 15th, 2012, 10:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

When I run your code, the page doesn't look in Design View nor in the browser. Which browser did you test this on? I had to make the following changes to the master page:

1. Change Maincontent to MainContent (the CSS selector uses MainContent with a capital C)

2. Change footer to Footer

With these changes, the page looked OK in Design View and in the browser.

Hope this helps.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 15th, 2012, 11:04 AM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

IE9. I would attach pics, but not sure if it is possible. I will try your suggestions. s.
 
Old May 15th, 2012, 11:10 AM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar, Sugesstions worked. "Design" now looks same as in the browser. Thanks. I'll watch my case closer from now on. BTW, you book rocks! Fantastic resource.
 
Old May 17th, 2012, 11:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
BTW, you book rocks! Fantastic resource.
Thank you!

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging of master page and aspx page MohamedHassanAli BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 2 March 9th, 2011 12:42 AM
Setting the Master page hoses site... Page 92... richv BOOK: Beginning SharePoint 2010 Development 19 December 30th, 2010 10:21 AM
Master Page Method: Code-Behind for Content Page kwilliams ASP.NET 2.0 Professional 3 June 2nd, 2008 12:57 PM
Master Page and Content Page with Java script Harjinder ASP.NET 2.0 Professional 1 February 1st, 2008 10:31 AM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.