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 March 20th, 2013, 01:30 PM
Authorized User
 
Join Date: Jun 2012
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Question Try-it-out on p. 284 - DisplayDirection not recognized

Hi Imar,

I'm working on the Try-it-out on p.284 ("Creating Smarter User Controls") for the second time in C#. The first time I did it, the banners did not show up. On my second try, I have a new problem. I followed the directions to the letter, and VWD refuses to recognize DisplayDirection. The error keeps popping up saying "Attribute 'DisplayDirection' is not a valid attribute of element 'Banner'".

First, here is my code-behind for my Banner control:
Code:
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_Banner : System.Web.UI.UserControl
{
	public Direction DisplayDirection { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
		  HorizontalPanel.Visible = false;
			VerticalPanel.Visible = false;

			switch (DisplayDirection)
			{
			  case Direction.Horizontal:
				  HorizontalPanel.Visible = true;
					break;
				case Direction.Vertical:
				  VerticalPanel.Visible = true;
					break;
			}
    }
}
Next, the markup for the banner control:

Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>
<asp:Panel ID="VerticalPanel" runat="server">
 <a href="http://p2p.wrox.com" target="_blank">
	<asp:Image ID="Image1" runat="server" AlternateText="This is a sample banner" 
		ImageUrl="~/Images/Banner120x240.gif" />
 </a>
</asp:Panel>

<asp:Panel ID="HorizontalPanel" runat="server">
 <a href="http://p2p.wrox.com" target="_blank">
	<asp:Image ID="Image2" runat="server" AlternateText="This is a sample banner" 
		ImageUrl="~/Images/Banner468x60.gif" />
 </a>
</asp:Panel>
Third, my Direction class:

Code:
public enum Direction
{
  Horizontal,
	Vertical
}
And last, my master file.

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 id="Head1" 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 id="A1" 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>
    	<br />
			<br />
			<Wrox:Banner ID="Banner1" runat="server" DisplayDirection="Horizontal" />
			<br />
    </div>
    <div id="Footer">Footer Goes Here</div>
  </div>
  </form>
</body>
</html>
I can't imagine why I could be getting that error. I followed everything to the letter. Any help will be greatly appreciated.

GreenhornPup
 
Old March 22nd, 2013, 06:03 PM
Authorized User
 
Join Date: Nov 2012
Posts: 40
Thanks: 8
Thanked 5 Times in 4 Posts
Default

I looked again and again and even tried out the complete try-out twice [with the above code].
Strange but it is working over mine machine, didn't got the above error.

May be you should try to run the source code from the same chapter in order to know if there are any external problems rather then the above code.

Last edited by 07Raghav; March 23rd, 2013 at 06:41 AM..
 
Old March 23rd, 2013, 06:29 PM
Authorized User
 
Join Date: Jun 2012
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I haven't seen Imar here lately. Is he on vacation?
 
Old March 26th, 2013, 11:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you try restarting Visual Studio? Sometimes it doesn't pick up the change and needs to be restarted for it to see the new property.

If that doesn't help, check the Errors list and make sure you don't have any other errors that prevent the site from compiling correctly.


Quote:
I haven't seen Imar here lately. Is he on vacation?
A business trip to New Orleans, but with enough fun to make it feel like a vacation ;-)

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!

Last edited by Imar; March 26th, 2013 at 11:51 AM.. Reason: Spelling
 
Old March 26th, 2013, 01:11 PM
Authorized User
 
Join Date: Jun 2012
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
A business trip to New Orleans, but with enough fun to make it feel like a vacation ;-)
Lucky duck





Similar Threads
Thread Thread Starter Forum Replies Last Post
Errata Lesson 23 pg.284 RMADANAT BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 1 February 2nd, 2012 03:16 PM
Chapter 8 p 284-287 wrighwj BOOK: Beginning ASP.NET 4 : in C# and VB 1 September 3rd, 2011 08:30 AM
DisplayDirection not liked member4953 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 10 April 1st, 2009 03:16 AM
284 Errors, 3 Warnings in sketcher Ch15 bgwinn Visual C++ 2005 3 August 6th, 2008 05:40 PM
1>Sketcher - 284 error(s), 3 warning(s) shade cat BOOK: Ivor Horton's Beginning Visual C++ 2005 1 July 21st, 2008 08:50 PM





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