Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 6th, 2010, 08:01 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #2 (permalink)  
Old July 6th, 2010, 08:51 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #3 (permalink)  
Old July 7th, 2010, 02:57 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 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!
Reply With Quote
  #4 (permalink)  
Old July 7th, 2010, 07:04 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #5 (permalink)  
Old July 8th, 2010, 02:30 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 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!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10: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 05:51 AM



All times are GMT -4. The time now is 08:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.