Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 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 January 19th, 2009, 08:29 AM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default Problem with try it out Chapter 11 p 408

hi there,
On this example, when a value is picked from the drop down menu then must bring automatically the proper theme. But it does not. Tried the done example and has the same problem. Here is the class’s code.


using System;
using System.Web;
using System.Web.UI;



namespace Osfp.Web.GlobalEvents
{
public class bgclass : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(this.app_PreRequestHandlerExecute);
}

private void app_PreRequestHandlerExecute(object Sender, EventArgs E)
{
Page p = HttpContext.Current.Handler as Page;
if (p != null)
{
ProfileCommon pb = (ProfileCommon)HttpContext.Current.Profile;
p.Theme = pb.Theme;
}
}
public void Dispose()
{
}
}
}
 
Old January 19th, 2009, 12:45 PM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

anyone ?
 
Old January 20th, 2009, 03:45 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 there,

What exactly is the problem. Do you get an error? If so, which one?

Also, you probably need to configure the handler in the webconfig. Have you done that?

Finally, what happens when you set a breakpoint on the line that starts with "Page p" and then debug your site. Does the breakpoint get hit?

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 January 20th, 2009, 11:57 AM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

what i want to do is, when i pick a value from the drop down menu, to automatically change the background. this happens, but only when i change a web page. i tried to add autopostback=true in the drop down menu but did not change anything.
hope this helps
 
Old January 20th, 2009, 11:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you answe the other questions? Otherwise it's difficult to suggest something useful...


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 January 20th, 2009, 12:09 PM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

Well i do not get any erros.
i have configured the handler in the webconfig.

When i add the break point to the place you told me and run it, the goes throung the if statment and loads the theme

In my case, what i am trying to do is when i pick a value from the drop down menu to load it automatically without loading other page to view the different theme.
 
Old January 20th, 2009, 12:13 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think I know what the problem is...

Themes are applied pretty early in the page's life cycle. So, when you set the theme after a postback, the current theme is already loaded, and the new theme settings are not applied.

The usual way around this is to redirect after them has been applied. Something like:

Response.Redirect(Request.Url.ToString();

should do the trick....

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 January 20th, 2009, 12:15 PM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

so but i am well amature, could you please tell me where to past this code?
thank you!
 
Old January 20th, 2009, 12:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Directly after the line that sets the profile. You may not have direct access to the Response and Request objects. If that's the case, you need to use HttpContext.Current. like this:

p.Theme = pb.Theme;
HttpContext myContext = HttpContext.Current;
myContext.Response.Redirect(myContext.Request.Url. ToString());

Hope this helps,

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 January 20th, 2009, 12:25 PM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

unfortunately an Error appeard
'System.Web.HttpContext' does not contain a definition for 'myContext'

i also tried the first option you told me with the same result!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 11 - Problem Opening Database dbcook8 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 15 February 2nd, 2009 08:41 AM
Problem with chapter 11 example luis.filipe BOOK: Expert SQL Server 2005 Integration Services ISBN: 978-0-470-13411-5 1 January 5th, 2008 05:29 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM
problem with chapter 11 example... shepholland BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 October 10th, 2004 10:12 AM





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