View Single Post
  #1 (permalink)  
Old March 20th, 2013, 01:30 PM
GreenhornPup GreenhornPup is offline
Authorized User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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:
 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;
				case Direction.Vertical:
				  VerticalPanel.Visible = true;
Next, the markup for the banner control:

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

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

public enum Direction
And last, my master file.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPages_Frontend" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
  <asp:ContentPlaceHolder ID="head" runat="server">
  <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: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">
      <br />
      <br />
      <asp:ContentPlaceHolder ID="cpMainContent" runat="server">
    <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="Horizontal" />
			<br />
    <div id="Footer">Footer Goes Here</div>
I can't imagine why I could be getting that error. I followed everything to the letter. Any help will be greatly appreciated.

Reply With Quote