Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 Search this Thread Display Modes
  #11 (permalink)  
Old January 20th, 2009, 12:33 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Can you post your exact code? The error message seems to suggest you implemented it differently....

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!
  #12 (permalink)  
Old January 20th, 2009, 12:38 PM
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

this is the code in the .cs file :

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


namespace Osfp.Web.GlobalEvents
{
publicclassbgclass : IHttpModule
{
publicvoid Init(HttpApplication context)
{
context.PreRequestHandlerExecute +=
newEventHandler(this.app_PreRequestHandlerExecute);
}
privatevoid app_PreRequestHandlerExecute(object Sender, EventArgs E)
{
Page p = HttpContext.Current.Handler asPage;
if (p != null)
{
ProfileCommon pb = (ProfileCommon)HttpContext.Current.Profile;
p.Theme = pb.Theme;
HttpContext.myContext = HttpContext.Current;
myContext.Response.Redirect(myContext.Request.Url. ToString());

}
}
publicvoid Dispose()
{
}
}
}
  #13 (permalink)  
Old January 20th, 2009, 12:43 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

There's a dot between HttpContext and myContext that shouldn't be there. So you need to change this:

HttpContext.myContext = HttpContext.Current;

to this:

HttpContext myContext = HttpContext.Current;

__________________
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!
  #14 (permalink)  
Old January 20th, 2009, 12:54 PM
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

i think is not the right place to paste that code...
when i run it, is tring to load but is does not.
anu other idea?
  #15 (permalink)  
Old January 20th, 2009, 12:58 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I am sorry. This is not the right place indeed. This is where the theme is applied from the profile. With this code there, you'll end up in a loop.

Instead, move it to the page where you set the profile based on the current DropDownList......

Sorry for the confusion....

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!
  #16 (permalink)  
Old January 20th, 2009, 01:02 PM
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

you mean in aspx.c#?
using System;
using System.Web;
using System.Web.UI.WebControls;

partial class FanClub : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
DisplayProfileProperties();
}
protected void btnCancelChanges_Click(object sender, System.EventArgs e)
{
DisplayProfileProperties();
}
protected void btnSaveChanges_Click(object sender, System.EventArgs e)
{
Profile.Theme = ((DropDownList)FCLoginview.FindControl("ThemeList" )).SelectedValue;
Profile.Name = ((TextBox)FCLoginview.FindControl("txtName")).Text ;
Profile.Address = ((TextBox)FCLoginview.FindControl("txtAddress")).T ext;
Profile.City = ((TextBox)FCLoginview.FindControl("txtCity")).Text ;
Profile.County = ((TextBox)FCLoginview.FindControl("txtCounty")).Te xt;
Profile.PostCode = ((TextBox)FCLoginview.FindControl("txtPostCode")). Text;
Profile.Country = ((TextBox)FCLoginview.FindControl("txtCountry")).T ext;
Profile.Mailings = ((CheckBox)FCLoginview.FindControl("chkMailing")). Checked;
Profile.Email = ((TextBox)FCLoginview.FindControl("txtEmail")).Tex t;
Profile.MemberName = ((TextBox)FCLoginview.FindControl("txtAlias")).Tex t;
Server.Transfer(SiteMap.CurrentNode.Url);
}
protected void FCLoginview_ViewChanged(object sender, System.EventArgs e)
{
DisplayProfileProperties();
}
private void DisplayProfileProperties()
{
TextBox NameBox = (TextBox)FCLoginview.FindControl("txtName");
if (NameBox != null)
{
((DropDownList)FCLoginview.FindControl("ThemeList" )).SelectedValue = Profile.Theme;
((TextBox)FCLoginview.FindControl("txtName")).Text = Profile.Name;
((TextBox)FCLoginview.FindControl("txtAddress")).T ext = Profile.Address;
((TextBox)FCLoginview.FindControl("txtCity")).Text = Profile.City;
((TextBox)FCLoginview.FindControl("txtCounty")).Te xt = Profile.County;
((TextBox)FCLoginview.FindControl("txtPostCode")). Text = Profile.PostCode;
((TextBox)FCLoginview.FindControl("txtCountry")).T ext = Profile.Country;
((CheckBox)FCLoginview.FindControl("chkMailing")). Checked = Profile.Mailings;
((TextBox)FCLoginview.FindControl("txtEmail")).Tex t = Profile.Email;
((TextBox)FCLoginview.FindControl("txtAlias")).Tex t = Profile.MemberName;
}
}

}
if so, in which procedure?
  #17 (permalink)  
Old January 20th, 2009, 01:05 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I don't have this book so I don't know this site, but you could try it instead of the Server.Transfer line. E.g. replace:

Server.Transfer(SiteMap.CurrentNode.Url);

with

Response.Redirect(Request.Url.ToString());
__________________
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!
  #18 (permalink)  
Old January 20th, 2009, 01:16 PM
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

i paste that code into the btnSaveChanges function and worked.
it only happens when i press the save button. any other idea?
  #19 (permalink)  
Old January 20th, 2009, 01:22 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Because this code is only triggered when you click the Save button:

protected void btnSaveChanges_Click(object sender, System.EventArgs e)
{
...
}

What would you like to happen and when?

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!
  #20 (permalink)  
Old January 20th, 2009, 01:28 PM
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 it does what i was expecting. when i press it, it changes the background.
but it would be more interesting to happened without pressing the button.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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



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


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