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 3rd, 2013, 01:59 PM
Registered User
Join Date: Feb 2013
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 8 pg 289 Clicking Button doesn't change banner

Step 3 of page 289 states that the button click will change the banner from vertical to horizontal because the Page_Load handler will not be run so the property on the page will not be affected, which is set at horizontal. However, my banner remains vertical after clicking the button. It seems the Page_Load handler is being run when the button is clicked which I understand is supposed to be a PostBack (and not supposed to run Page_Load?)

<%@ Page Title="About Us" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="AboutUs.aspx.cs" Inherits="About_AboutUs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <!-- Copyright (C) 2013 -->
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    Robin P
    Skills: <br />
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <br />
    <Wrox:Banner ID="Banner2" runat="server" DisplayDirection="Horizontal" />
Code Behind AboutUs.aspx.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 About_AboutUs : BasePage
    protected void Page_Load(object sender, EventArgs e)
        Banner2.DisplayDirection = Direction.Vertical;
I am using MVS Express 2012 for Web if that makes a difference. Thanks!
Old March 4th, 2013, 08:57 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,

Looks like you missed step 1 where the code is wrapped in a !Page.IsPostBack statement.

Page_Load always fires, on the initial request as well as on a postback (for example, when a button is clicked). The check for Page.IsPostBack in Page_Load causes the direction only to be set on the initial load.

Hope this helps,

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:
RobinP2K1 (March 4th, 2013)
Old March 4th, 2013, 09:56 PM
Registered User
Join Date: Feb 2013
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Silly me! Thank you.

I appreciate your quick help.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with double clicking on the button ranking system nir987 ASP.NET 3.5 Professionals 3 November 23rd, 2011 09:25 PM
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
Banner missing from Chapter 3 paleboat BOOK: Professional Joomla! ISBN: 978-0-470-13394-1 0 April 14th, 2009 04:20 PM
Running VBScript after clicking a submit button choby VB.NET 1 July 11th, 2006 07:33 PM
refresh and display new data after clicking button hosefo81 PHP How-To 0 January 1st, 2004 02:07 AM

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