Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : 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 February 25th, 2013, 02:24 PM
Registered User
 
Join Date: Feb 2013
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default Skins and CSS trouble

Hi Imar!

Thank you for writing a excellent book!

In Chapter 6 I'm having some trouble implementing the style for the button that uses a skin to give it a blue background and a .MyButton ID in the monochrome CSS to give it white text. The button seems to come out blue but the text does not get changed to white as specified in the CSS? Below are my code snippets

Button.skin
Code:
<asp:Button CssClass="MyButton" BackColor="#509EE7" runat="server" />
Web.config
Code:
<system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <pages styleSheetTheme="DarkGrey"></pages>
  </system.web>
Monochrome.css
Code:
.MyButton
{
    color: yellow;
}
SkinsDemo.aspx
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:Button ID="Button1" runat="server" Text="Button"/>
</asp:Content>
Thanx in advance :)
 
Old February 25th, 2013, 04:38 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Notice how the web.config file sets the theme to DarkGrey. You need to get rid of that and then select the Monochrome theme for this exercise to work.

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!
The Following User Says Thank You to Imar For This Useful Post:
Rossco (February 26th, 2013)
 
Old February 26th, 2013, 08:29 AM
Registered User
 
Join Date: Feb 2013
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Thumbs up

Thanx for the quick reply Imar!

I'm still having trouble with this even though I changed the theme in web.config to Monochrome. Additionally I have moved onto chapter 7 of implementing a menu on the website. I have made the changes to Monochrome.css file such as the action when the mouse hovers over the menu's and the different background colors etc. But none of these changes come into effect when I run the website in Firefox. I seem to think it is much the same problem as with the button skin. It is like the controls aren't inheriting the styles from the monochrome.css file?

I have opened your source files from chapter 6 and 7 and my code seems to be the same? I must be missing something? I'm using FireFox11 not the latest 12 do you think that could maybe be the problem?

Thanx for the assistance!
 
Old February 26th, 2013, 08:33 AM
Registered User
 
Join Date: Feb 2013
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default

My Code:

Web.config:
Code:
 <system.web>
    <pages theme="Monochrome"></pages>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
Frontend.master:
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <script src="../Scripts/modernizr-2.6.2.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="PageWrapper">
            <header><a href="/"></a></header>
            <nav>
                <asp:Menu ID="Menu1" runat="server" CssClass="MainMenu" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False"></asp:Menu>
                <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
            </nav>
            <section id="MainContent">
                <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath><br /><br />
                <asp:ContentPlaceHolder ID="cpMainContent" runat="server">
                </asp:ContentPlaceHolder>
            </section>
            <aside id="Sidebar">Select a theme <br />
                <asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ThemeList_SelectedIndexChanged">
                    <asp:ListItem>Monochrome</asp:ListItem>
                    <asp:ListItem>Dark Grey</asp:ListItem>
                </asp:DropDownList></aside>
            <footer>Footer Goes Here</footer>
        </div>
    </form>
</body>
</html>
Monochrome.css:
Code:
.MyButton
{
    color: white;
}
ul.level1
{
    /*Defines the appearence of the main menue items.*/
    font-size: 14px;
    font-weight: bold;
    height: 19px;
    line-height: 19px;
}
    ul.level1 .selected
    {
        /*Defines the appearance of active menu items.*/
        background-color: #509EE7;
    }
a.level1
{
    /*Adds some white space to the left of the main menu item text
          !important is used to overrule the in-line CSS that the menu generates*/
    padding-left: 5px !important;
}
a.level2
{
    /*Defiens the appearance of the sub menu items.*/
    background-color: #555555;
    padding-left: 8px;
}
    a.level1:hover, a.level2:hover
    {
        /*defines the hover style for the main and sub items.*/
        background-color: #509EE7;
    }
 
Old February 26th, 2013, 08:37 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,

Do other changes in the CSS show up? Or is nothing applied? Have you tried a hard refresh (Ctrl+R or Ctrl+F5) in the browser? And can you post the full code of the final page in the browser?

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!
The Following User Says Thank You to Imar For This Useful Post:
Rossco (February 26th, 2013)
 
Old February 26th, 2013, 08:56 AM
Registered User
 
Join Date: Feb 2013
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Haha I feel pretty stupid now. The (Ctrl-R) worked and displayed the updated styles.

Thank you very much for your assistance!





Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS vs Skins vbboyd BOOK: Beginning ASP.NET 4 : in C# and VB 1 June 7th, 2012 02:50 AM
ch6 Skins and Named Skins wingri BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 8th, 2008 02:57 AM
Advanced Themes, Skins and CSS adam_kahtava ASP.NET 2.0 Professional 1 April 3rd, 2007 07:25 PM
CSS and ASP.NETs Themes, and Skins adam_kahtava CSS Cascading Style Sheets 1 November 13th, 2006 08:58 PM
trouble changing css styles with javascript donrafeal7 Javascript 4 October 23rd, 2006 11:30 AM





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