Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
| Search | Today's Posts | Mark Forums Read
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 23rd, 2011, 03:16 AM
Registered User
 
Join Date: Apr 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Question Creating a Skin for the Button Control, Ch6, Skins ???

I'm stuck on the "Creating a Skin for the Button Control" Try it out within Chapter 6. I have the Kindle book so no page numbers, sorry.

I'm using Visual Studio 2010 Professional, I have SQL Server 2008 Developer installed on the backend but haven't gotten to any excercises that use it. I'm coding in Visual Basic.


I have worked through the book and am now stuck on an issue I'm not sure how to fix. I've created the SkinsDemo.aspx file and added the Button control:

<%@ Page Title="Skins Demo" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="SkinsDemo.aspx.vb" 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>



I've created the Button.skin file within the Monochrome.css Directory:

<asp:Button
CssClass="MyButton" BackColor="#7a70a4" runat="server" />



I've altered the Monochrome.css file to include the .MyButton class:

...
...
.MyButton
{
color: White;
}



I do not have a DarkGrey.skin file and I do not have a .MyButton class within the DarkGrey.css file.

My problem is when I "view in browser" the SkinsDemo.aspx file and switch between the DarkGrey and Monochrome themes, the button color doesn't change as it should. The code works and the Button is purple with white text as the skin and Monochrome.css file declare but, it is also purple with white text when the DarkGrey theme is selected. Why are the Monochrome.css and Button.skin settings showing up in the DarkGrey theme??? Or, to put it another way, why is it when I go from the Monochrome theme to the DarkGrey theme, are Monochrome skin and the Monochrome.css settings showing up in the DarkGrey theme settings?

Now, I realize that if I add the .MyBotton class to the DarkGrey.css file and change the color settings to something other then white then the button text will indeed change colors when moving from one theme to another. However, this doesn't seem to be a work around the problem becuase ,then I would have to explicitly add the same classes to both theme.css files that have seperate functionality, everytime i wanted a custom skin for an asp control in a theme.

Please Help
Thank you

Christopher
 
Old April 23rd, 2011, 03:56 AM
Registered User
 
Join Date: Apr 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Cool I think I figured it out...

Within the web.confix xml file I still had the page code:

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

Once this line was removed the code functioned as expected.
 
Old April 23rd, 2011, 04:17 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Once this line was removed the code functioned as expected.
You may not want to delete the entire line, but just the styleSheetTheme. When you delete theme as well, new users without a cookie won't have a default theme.

By removing styleSheetTheme, the programmatic theme you set (DarkGrey) is the only one applied. If you keep styleSheetTheme set to Monochrome, you actually get the two themes applied at the same time (though at different stages) which gives you odd and mixed results.

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:
EDGY (July 5th, 2012)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch6 Creating a WebPart Page and Chart Web Part cchiang12 BOOK: Beginning SharePoint 2010 Development 0 November 16th, 2010 11:39 AM
Creating a skin file issue bpl BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 October 27th, 2009 07:39 PM
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
Skin Custom Control vishwjeet ASP.NET 2.0 Basics 0 June 23rd, 2007 02:10 PM
Creating Form skins/Theme chiefouko Pro VB.NET 2002/2003 0 September 14th, 2004 12:15 AM





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