Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 July 6th, 2010, 08:01 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default BasePage Issue regarding Theme property setting

My runtime error is:

The 'Theme' property can only be set in or before the 'Page_PreInit' event

After implimenting the c# code chapter 6 page 227. This occurs when the following event handler is put in place:

this.PreRender += newEventHandler(Page_PreInt);

If thats commented out it runs. Here is my offending BasePage class:

Code:
publicclassBasePage : System.Web.UI.Page
{
privatevoid Page_PreRender(object sender, EventArgs e)
{
if (this.Title == "" || this.Title == null || this.Title.Length == 0)
{
thrownewException("Page title cannot be an empty string.");
}
}
privatevoid Page_PreInt(object sender, EventArgs e)
{
HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme");
if (preferredTheme != null)
{
Page.Theme = preferredTheme.Value;
}
}
public BasePage()
{
this.PreRender += newEventHandler(Page_PreRender);
this.PreRender += newEventHandler(Page_PreInt);
}
}
What have I done wrong?

TYIA
__________________
Wind is your friend
Matt
 
Old July 6th, 2010, 08:51 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

OMG those CODE tags mess things up....

Anyhow my mistake. The last line of the code should have been:

this.PreInit += newEventHandler(Page_PreInit);
__________________
Wind is your friend
Matt
 
Old July 7th, 2010, 02:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Matt,

If you post colored code from Visual Studio, use the Remove Text Formatting button on the post editor before you wrap it in code tags. That should fix the issue.

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!
 
Old July 7th, 2010, 07:04 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Cheers Imar - I have never used these code tags before. Hopefully people havnt been to annoyed at my invlovement in the Classic area of Wrox simply pasting code directley over the years...
__________________
Wind is your friend
Matt
 
Old July 8th, 2010, 02:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You don't have to use them, but I think if you don't, indention gets lost. E.g. all double spaces are converted to just one, making code harder to read.

The fact the editor is so buggy doesn't make this any easier. You should be able to just post whatever you want, code tags or not...... ;-)

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 6 p226 preferred theme in basepage robbaralla BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 November 7th, 2009 11:24 AM
BasePage and Namespace Issue Eric S. Smith BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 May 28th, 2008 08:43 AM
Setting Theme in Master Page rodmcleay General .NET 12 April 9th, 2008 05:24 AM
theme selector inputcontrol highlight issue michaelitrn BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 10th, 2006 02:58 PM
Setting "DBEngine.SystemDB" property jkuusik BOOK: Access 2003 VBA Programmer's Reference 2 December 28th, 2005 06:51 AM





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