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 October 18th, 2010, 01:19 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2010
Posts: 56
Thanks: 17
Thanked 2 Times in 2 Posts
Default Ch11 p378 Step 7 - no fade?

My banner isn't fading!
Can't find the error.

I tried the book's source code for frontend.master and BasicSelector,aspx but it still doesn't fade.

Where might I have made the error?

<%@ Page Title="Basic Selectors Demo" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="BasicSelectors.aspx.cs" Inherits="Demos_BasicSelectors" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="Server">
  <h1>Basic Selectors</h1>
  <div class="SampleClass">I am a div.</div>
<asp:Content ID="Content3" runat="server" ContentPlaceHolderID="cpClientScript">
  <script type="text/javascript">
    $(function ()
      $('*').css('color', 'Green');                                 // Universal
      $('#Footer').css('border-bottom', '2px solid black');         // ID
      $('h1').bind('click', function () { alert('Hello World') });  // Element
      $('.SampleClass').addClass('PleaseWait').hide(5000);          // Class
      $('#Footer, #Header').slideUp('slow').slideDown('slow');      // Grouped
      $('#Sidebar img').fadeTo(5000, 0.1);                          // Combined
<%@ 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">
    <asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <asp:ScriptReference Path="~/Scripts/jquery-1.4.1.min.js" />
    <div id="PageWrapper">
      <div id ="Header"><a href="~/" runat="server">Header goes here</a> </div>
      <div id ="MenuWrapper">
        <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" 
          Orientation="Horizontal" StaticEnableDefaultPopOutImage="False"></asp:Menu>
          <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" ShowExpandCollapse="False">
          <asp:TreeNodeStyle CssClass="FirstLevelMenuItems" />
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" 
          ShowStartingNode="False" />
      <div id ="MainContent"> 
      <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath> <br /> <br />
      <asp:ContentPlaceHolder ID="cpMainContent" runat="server">This is default text that shows up in content pages that don't explicitly override it.</asp:ContentPlaceHolder></div>
      <div id ="SideBar">Select a Theme <br /><asp:DropDownList ID="ThemeList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ThemeList_SelectedIndexChanged">
        <br />
        <br />
        <Wrox:Banner ID="Banner1" runat="server" DisplayDirection="Vertical" />
        <br />
      <div id ="Footer">Footer goes here</div> 
    <asp:ContentPlaceHolder ID="cpClientScript" runat="server">
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).Selected = true;

      switch (Page.Theme.ToLower())
        case "darkgrey":
          Menu1.Visible = false;
          TreeView1.Visible = true;
          Menu1.Visible = true;
          TreeView1.Visible = false;

    protected void ThemeList_SelectedIndexChanged(object sender, EventArgs e)
      HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
      preferredTheme.Expires = DateTime.Now.AddMonths(3);
      preferredTheme.Value = ThemeList.SelectedValue;
Old October 19th, 2010, 04:14 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

The ID of the Sidebar in your Master Page is spelled as SideBar, while your jQuery code uses Sidebar with a lower case b. Always check the spelling of the controls you're addressing when you find that your jQuery code doesn't run as the code is case sensitive. Just change SideBar to Sidebar in the Master Page (to stick with how the book does it)and I think it should work.


Imar Spaanjaars
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:
ken evans (October 19th, 2010)
Old October 19th, 2010, 04:33 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2010
Posts: 56
Thanks: 17
Thanked 2 Times in 2 Posts

Hi Imar,
Thanks for taking the time to find this mistake of mine.
It works OK now.

Now to Ch 12!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash - fade in then stay Teessider_2000 Flash (all versions) 2 August 16th, 2007 02:57 PM
fade in not working in FF but does in IE crmpicco Javascript How-To 1 November 8th, 2005 12:49 PM
We Based Database Step By step desireemm SQL Language 1 October 15th, 2005 08:15 PM
fade in/fade out on a div with JavaScript crmpicco Javascript How-To 1 September 23rd, 2005 04:27 AM
javascript image fade in fade out crmpicco Javascript How-To 0 September 12th, 2005 11:02 AM

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