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

January 20th, 2009, 12:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you post your exact code? The error message seems to suggest you implemented it differently....
Imar
|
|

January 20th, 2009, 12:38 PM
|
|
Authorized User
|
|
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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()
{
}
}
}
|
|

January 20th, 2009, 12:43 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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;
|
|

January 20th, 2009, 12:54 PM
|
|
Authorized User
|
|
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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?
|
|

January 20th, 2009, 12:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

January 20th, 2009, 01:02 PM
|
|
Authorized User
|
|
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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?
|
|

January 20th, 2009, 01:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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());
|
|

January 20th, 2009, 01:16 PM
|
|
Authorized User
|
|
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
|
|
i paste that code into the btnSaveChanges function and worked.
it only happens when i press the save button. any other idea?
|
|

January 20th, 2009, 01:22 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

January 20th, 2009, 01:28 PM
|
|
Authorized User
|
|
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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.
|
|
 |