 |
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
|
|
|
|
|

June 26th, 2012, 10:08 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 6: Creating a Skin for the Button Control
Hi There.
I need help, I don't understand why the .aspx of the Demo's folder it isn't run together with the default.aspx of the root. For example, I can not see the CalculatorDemo of the Demo's folfer, I just see the Planet Wrox. Is for the master page?
I go for the page 234, in the Try It Out "Creating a Skin for the Button Control", I have trouble in the number 4, when I add the Web Form called SkinsDemo.aspx, it's not show the button purple with the Planet Wrox, I only see the button purple when I do right click in the SkinsDemo.aspx, it's alone.
Please, somebody explain what it's wrong
PD: Excuse my bad english, it's very basic.
|
|

June 27th, 2012, 08:34 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
I read your question over and over, but I don't undersstand what you're asking. Can you describe, step by step, what you're doing and what the problem is?
Imar
|
|

June 27th, 2012, 09:54 AM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for answering.
The problem is when I add the button on SkinsDemo.aspx of the page 234 (Creating a Skin for the Button Control), that button, it isn't shown on the browser, I try everything and nothing.
I notice that all aspx of demo's folder, they are not shown on browser when I press ctrl+f5 including SkinsDemo. I asked myself, why?
|
|

June 27th, 2012, 10:07 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
I notice that all aspx of demo's folder, they are not shown on browser when I press ctrl+f5 including SkinsDemo. I asked myself, why?
|
They are not shown at all? Or are they not using the theme?
Imar
|
|

August 16th, 2012, 12:49 AM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello,
I reached this point in the tutorial and found that SkinsDemo.aspx is stuck in Monochrome, even when I select DarkGrey, and the button stays purple. When I open the Default.aspx it starts in Monochrome, forgetting my previous choice, but at least it allows me to switch to DarkGrey.
Here are my settings...
web.config: <pages theme="Monochrome"></pages>
BasePage.cs: same as Source file
Button.skin: <asp:Button CssClass="MyButton" BackColor="#7a70a4" runat="server" />
Monochrome.css:
.MyButton
{
color: White;
}
???
|
|

August 17th, 2012, 02:06 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Can you post the full code for the master page (markup and code behind), BasePage, web.config and the page you're testing this on?
Also, make sure your pages inherit from the BasePage instead of from the standard .NET Page.
Cheers,
Imar
|
|

August 18th, 2012, 01:43 AM
|
|
Registered User
|
|
Join Date: Aug 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
I started over at the point of recreating the template and the skin exercise is working now. However, I am still having trouble with the theme cookie -- pages always open in Monochrome.
BTW: Thanks for all the hard work! Good tutorials are hard to come by.
Here's my code...
Frontend.master:
<%@ 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">Menu Goes Here</div>
<div id="MainContent">
<asp:ContentPlaceHolder ID="cpMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="Sidebar">Choose a theme<br />
<asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True"
onselectedindexchanged="ThemeList_SelectedIndexCha nged">
<asp:ListItem>Monochrome</asp:ListItem>
<asp:ListItem>DarkGrey</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Footer">Footer Goes Here</div>
</div>
</form>
</body>
</html>
Frontend.master.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MasterPages_Frontend : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string selectedTheme = Page.Theme;
HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
if (preferredTheme != null)
{
selectedTheme = preferredTheme.Value;
}
if (!string.IsNullOrEmpty(selectedTheme) && ThemeList.Items.FindByValue(selectedTheme) != null)
{
ThemeList.Items.FindByValue(selectedTheme).Selecte d = true;
}
}
}
protected void ThemeList_SelectedIndexChanged(object sender, EventArgs e)
{
HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
preferredTheme.Expires = DateTime.Now.AddMonths(3);
preferredTheme.Value = ThemeList.SelectedValue;
Response.Cookies.Add(preferredTheme);
Response.Redirect(Request.Url.ToString());
}
}
BasePage.cs:
using System;
using System.Web;
public class BasePage : System.Web.UI.Page
{
private void Page_PreInit(object sender, EventArgs e)
{
HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
if (preferredTheme != null)
{
Page.Theme = preferredTheme.Value;
}
}
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.");
}
}
public BasePage()
{
this.PreRender += new EventHandler(Page_PreRender);
this.PreInit += new EventHandler(Page_PreInit);
}
}
web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<!--<pages theme="DarkGrey" styleSheetTheme="DarkGrey"></pages>-->
<pages theme="Monochrome"></pages>
<compilation debug="false" targetFramework="4.0" />
</system.web>
</configuration>
Default.aspx:
<%@ Page Title="Welcome to Planet Wrox" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<h1>
Hi there visitor and welcome to Planet Wrox</h1>
<p class="Introduction">
We're glad you're <span class="style1">paying a visit</span> to
<a href="http://www.PlanetWrox.com">www.PlanetWrox.com</a>, the coolest music
community site on the Internet.</p>
<p class="Introduction">
Feel free to have a <a href="Default.aspx">look around</a>; there are lots of
interesting <strong>reviews & concert</strong> pictures to be found here.</p>
<p>
You can <a href="Login.aspx">log in</a> here</p>
</asp:Content>
|
|
 |
|