Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
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 June 29th, 2010, 07:03 PM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default SkinsDemo.aspx doesnt show the color of the button

i followed all the instruction the the chapter 6 Skins|235 to create a button which then on the browser meant to show the button with purple background and white text but it doesnt show... i looked on the html source and

has this line
<input type="submit" name="ctl00$cpMainContent$Button2" value="Button" id="cpMainContent_Button2" />

which should also have a class="Mybutton" style="background-color":#7a704;"

but it doenst what could be missing could be because the file is on the Demo folder instead of on the monochronome folder

this my codes
PHP Code:
<%@ Page Title="Skins Demo " Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="SkinsDemo.aspx.cs" Inherits="Demos_SkinsDemo" %>

<
asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</
asp:Content>
<
asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <
asp:Button ID="Button1" runat="server" Text="Button" />
</
asp:Content
PHP Code:
<asp:Button CssClass="MyButton" BackColor="#7a70a4" runat="server" /> 

Last edited by eurico; June 29th, 2010 at 07:13 PM..
 
Old June 30th, 2010, 01:44 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 be a bit more specific? How does your Content Page look? Where exatly did you save the Skin file? With what name and what code? How does the CSS class look and in which file did you save it?

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 June 30th, 2010, 11:50 AM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi the skin file i saved on the Demos folder so is like this the structure of the files


Site {Folder App_themes {folder Monochrome{ File<Button.skin>}

Site {Folder App_themes {folder Monochrome{ File<Monochrome .css>}

Site {Folder Demos {file<SkinsDemo>}


Button.skin code
PHP Code:
<asp:Button CssClass="MyButton" BackColor="#7a70a4" runat="server" /> 
SkinsDemo.aspx
PHP Code:
<%@ Page Title="Skins Demo " Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="SkinsDemo.aspx.cs" Inherits="Demos_SkinsDemo" %>

<
asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</
asp:Content>
<
asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <
asp:Button ID="Button1" runat="server" Text="Button" />
</
asp:Content
Monochrome .css
PHP Code:
.MyButton
{
  
colorWhite;  

Web config
PHP Code:
<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
   
        <compilation debug="false" targetFramework="4.0" />
    </system.web>

</configuration>
 
Old June 30th, 2010, 11:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is that all the code in the web.config? Looks like you haven't set the theme?

For more details, check out page 222, step 5.

Cheers,

Imarr
__________________
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 June 30th, 2010, 12:06 PM
Authorized User
 
Join Date: May 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like this line was missing

<pages theme="Monochrome"></pages>

thanks
 
Old February 13th, 2011, 11:09 PM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having a similar-but-opposite problem to eurico's... I'm seeing a purple button with white lettering regardless of which theme I select at runtime, though the other page elements change correctly when I change themes. I have the theme set to Monochrome in my web.config. BUT if I change my web.config setting to DarkGrey and re-view SkinsDemo.aspx in my browser, the button changes color correctly. Any idea what I'm doing wrong?

Thanks,
Jerry
 
Old February 14th, 2011, 02:40 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 your code for the following items:

1. The <pages /> element of web.config

2. The Code Behind of your Master Page

3. The code for your BasePage

4. Your Skin file

5. The code for the button?

Makes it easier which part of the puzzle is missing.

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 February 14th, 2011, 09:53 PM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I was hoping the problem would be glaringly obvious from my brief description. Here ya go...

1. The <pages /> element of web.config

Code:
<pages theme="Monochrome"></pages>
2. The Code Behind of your Master Page

Code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPages_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>
</head>
<body>
    <form id="form1" runat="server">
        <div id="PageWrapper">
            <div id="Header"><a href="~/" runat="server"></a></div>
            <div id="MenuWrapper">
                <asp:Menu ID="Menu1" runat="server" CssClass="MainMenu" 
                    DataSourceID="SiteMapDataSource1" Orientation="Horizontal" 
                    StaticEnableDefaultPopOutImage="False">
                </asp:Menu>
                <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" 
                    ShowExpandCollapse="False">
                    <LevelStyles>
                        <asp:TreeNodeStyle CssClass="FirstLevelMenuItems" />
                    </LevelStyles>
                </asp:TreeView>
                <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" 
                    ShowStartingNode="False" />
            </div>
            <div id="MainContent">
                <asp:SiteMapPath ID="SiteMapPath1" runat="server">
                </asp:SiteMapPath><br /><br />
                <asp:ContentPlaceHolder ID="cpMainContent" runat="server"></asp:ContentPlaceHolder>
            </div>
            <div id="Sidebar">
                Select a Theme<br />
                <asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ThemeList_SelectedIndexChanged">
                    <asp:ListItem>Monochrome</asp:ListItem>
                    <asp:ListItem>DarkGrey</asp:ListItem>
                </asp:DropDownList>
            </div>
            <div id="Footer">Footer Goes Here</div>
        </div>
    </form>
</body>
</html>
3. The code for your BasePage

Code:
using System;
using System.Web;

public class BasePage : System.Web.UI.Page
{
    private void Page_PreRender(object sender, EventArgs e)
    {
        if (this.Title == "Untitled Page" || string.IsNullOrEmpty(this.Title))
        {
            throw new Exception("Page title cannot be \"Untitled Page\" or an empty string.");
        }
    }

    private void Page_PreInit(object sender, EventArgs e)
    {
        HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
        if (preferredTheme != null)
        {
            Page.Theme = preferredTheme.Value;
        }
    }

    public BasePage()
    {
        this.PreRender += new EventHandler(Page_PreRender);
        this.PreInit += new EventHandler(Page_PreInit);
    }
}
4. Your Skin file

Code:
<asp:Button CssClass="MyButton" BackColor="#7a70a4" runat="server" />
<asp:Button BackColor="Red" ForeColor="Black" SkinID="RedButton" runat="server" />
5. The code for the button?

Code:
<%@ Page Title="Skins Demo" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="SkinsDemo.aspx.cs" Inherits="Demos_SkinsDemo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:Button ID="Button2" runat="server" Text="Button" SkinID="RedButton" />
</asp:Content>
 
Old February 15th, 2011, 05:12 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 Jerry,

Not sure what's going on. I tested your code in my sample site and it all seems to work fine. When I request SkinsDemo in the Monochrome theme, I have a purple and a Red button. When I switch to DarkGrey, both buttons are grey.

The only reason for a problem could be in:

1. The code *behind* of the master page. You posted the code before / markup, but in the code behind the cookie is set for the selected theme. However, you say that theme switching seems to work fine for the other elements so I doubt this is the case.

2. Your skin file's location / name.

Are you seeing the same behavior with the code from the book? If not, can you make available a zipped copy of your web site so I can take a look?

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
Link button in nested grids clcik doesnt work fir RaghaSM ASP.NET 2.0 Basics 1 June 26th, 2008 12:05 AM
.aspx.vb file doesnt run arabuafef ASP.NET 2.0 Professional 7 March 18th, 2008 12:20 PM
Button doesnt work help john111 Java GUI 4 March 21st, 2006 05:22 PM
Button doesnt play sound john111 Java Basics 0 March 7th, 2006 06:49 AM
Float causing background-color not to show wheelie CSS Cascading Style Sheets 3 January 24th, 2006 07:29 AM





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