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 27th, 2015, 05:40 PM
Authorized User
Join Date: Oct 2015
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 8 Banner - both visible


I've been trying to work out why both banners are visible when the page loads.

Here is the code

<%@ Control Language="C#" AutoEventWireup="false" CodeFile="Banner.ascx.cs" Inherits="Controls_Banner" %>

<asp:Panel ID="VerticalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank" runat="server" id="VerticalLink">
<asp:Image ID="Image1" runat="server" AlternateText="This is a sample banner" ImageUrl="~/Images/Banner120x240.gif" />
<asp:Panel ID="HorizontalPanel" runat="server">
<a href="http://p2p.wrox.com" target="_blank" runat="server" id="HorizontalLink">
<asp:Image ID="Image2" runat="server" AlternateText="This is a sample banner" ImageUrl="~/Images/Banner468x60.gif" />

Code Behind
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; }

public string NavigateUrl
object _navigateUrl = ViewState["NavigateUrl"];
if (_navigateUrl != null)
return (string)_navigateUrl;
return "http://p2p.wrox.com"; // Return a default value
ViewState["NavigateUrl"] = value;

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

switch (DisplayDirection)
case Direction.Horizontal:
HorizontalPanel.Visible = true;
HorizontalLink.HRef = NavigateUrl;
case Direction.Vertical:
VerticalPanel.Visible = true;
VerticalLink.HRef = NavigateUrl;


<Wrox:Banner ID="Banner1" runat="server" DisplayDirection ="Horizontal" />

Can you help please?
Old October 27th, 2015, 06:07 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Maybe because you have another Banner control
in the page that uses this master?

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!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8 pg 289 Clicking Button doesn't change banner RobinP2K1 BOOK: Beginning ASP.NET 4 : in C# and VB 2 March 4th, 2013 09:56 PM
Chapter 8: banner web user control Antonius Block BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 August 6th, 2012 03:31 AM
Wrox:Banner (Chapter 11) Derrick T. Davidson BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 November 17th, 2011 10:40 PM
Chapter 8 Banner not being displayed in Chrome or Firefox TreyC BOOK: Beginning ASP.NET 4 : in C# and VB 2 May 27th, 2010 08:27 AM
Banner missing from Chapter 3 paleboat BOOK: Professional Joomla! ISBN: 978-0-470-13394-1 0 April 14th, 2009 04:20 PM

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