Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 19th, 2009, 07:29 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
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()
{
}
}
}
  #2 (permalink)  
Old January 19th, 2009, 11:45 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default

anyone ?
  #3 (permalink)  
Old January 20th, 2009, 02:45 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 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!
  #4 (permalink)  
Old January 20th, 2009, 10:57 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
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
  #5 (permalink)  
Old January 20th, 2009, 10:59 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 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!
  #6 (permalink)  
Old January 20th, 2009, 11:09 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
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.
  #7 (permalink)  
Old January 20th, 2009, 11:13 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 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!
  #8 (permalink)  
Old January 20th, 2009, 11:15 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
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!
  #9 (permalink)  
Old January 20th, 2009, 11:19 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 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!
  #10 (permalink)  
Old January 20th, 2009, 11:25 AM
Authorized User
 
Join Date: Dec 2008
Location: , , Greece.
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!
 


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 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 07: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 04: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 05: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



All times are GMT -4. The time now is 07:02 AM.


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