p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 (http://p2p.wrox.com/forumdisplay.php?f=264)
-   -   newsletter (http://p2p.wrox.com/showthread.php?t=54665)

vantoko February 27th, 2007 02:49 PM

newsletter
 
Hi,

I want to enable the user profile in that way that a html version of the newsletter is selected by default when registring.

in my userprofile.aspx I have :
 <asp:ListItem Text="HTML versie" Value="Html" Selected="true" />
            <asp:ListItem Text="Geen abonnement" Value="None" />
            <asp:ListItem Text="Plain tekst" Value="PlainText" />

in my enum.cs (in newsletter folder) I have :
public enum SubscriptionType : int
   {
      None = 0,
      PlainText = 1,
      Html
   }

However, it is still set to None when the new user enters the profile page.
What am I doing wrong ?

tnx

koen


englere February 28th, 2007 12:57 AM

Is the profile being read and then populating that listbox, even the very first time? What value goes into the profile when the user is first created?


vantoko February 28th, 2007 03:28 AM

Here is my pageload and save function.
Do you see anything ?

protected void Page_Load(object sender, EventArgs e)
      {
         if (!this.IsPostBack)
         {
            ddlCountries.DataSource = Helpers.GetCountries();
            ddlCountries.DataBind();

            // if the UserName property contains an emtpy string, retrieve the profile
            // for the current user, otherwise for the specified user
            ProfileCommon profile = this.Profile;
            if (this.UserName.Length > 0)
               profile = this.Profile.GetProfile(this.UserName);

            ddlSubscriptions.SelectedValue = profile.Preferences.Newsletter.ToString();
            ddlLanguages.SelectedValue = profile.Preferences.Culture;
            txtFirstName.Text = profile.FirstName;
            txtLastName.Text = profile.LastName;
            ddlGenders.SelectedValue = profile.Gender;
            if (profile.BirthDate != DateTime.MinValue)
               txtBirthDate.Text = profile.BirthDate.ToShortDateString();
           ddlSkiType.SelectedValue = profile.SkiInfo.Type;
            txtWebsite.Text = profile.Website;
            txtStreet.Text = profile.Address.Street;
            txtCity.Text = profile.Address.City;
            txtPostalCode.Text = profile.Address.PostalCode;
            txtState.Text = profile.Address.State;
            ddlCountries.SelectedValue = profile.Address.Country;
            txtPhone.Text = profile.Contacts.Phone;
            txtFax.Text = profile.Contacts.Fax;
            txtAvatarUrl.Text = profile.Forum.AvatarUrl;
            txtSignature.Text = profile.Forum.Signature;
                     }
      }

public void SaveProfile()
      {
         // if the UserName property contains an emtpy string, save the current user's profile,
         // othwerwise save the profile for the specified user
         ProfileCommon profile = this.Profile;
         if (this.UserName.Length > 0)
            profile = this.Profile.GetProfile(this.UserName);

         profile.Preferences.Newsletter = (SubscriptionType)Enum.Parse(typeof(SubscriptionTy pe), ddlSubscriptions.SelectedValue);
         profile.Preferences.Culture = ddlLanguages.SelectedValue;
         profile.FirstName = txtFirstName.Text;
         profile.LastName = txtLastName.Text;
         profile.Gender = ddlGenders.SelectedValue;
         if (txtBirthDate.Text.Trim().Length > 0)
            profile.BirthDate = DateTime.Parse(txtBirthDate.Text);
        profile.SkiInfo.Type = ddlSkiType.SelectedValue;
         profile.Website = txtWebsite.Text;
         profile.Address.Street = txtStreet.Text;
         profile.Address.City = txtCity.Text;
         profile.Address.PostalCode = txtPostalCode.Text;
         profile.Address.State = txtState.Text;
         profile.Address.Country = ddlCountries.SelectedValue;
         profile.Contacts.Phone = txtPhone.Text;
         profile.Contacts.Fax = txtFax.Text;
         profile.Forum.AvatarUrl = txtAvatarUrl.Text;
         profile.Forum.Signature = txtSignature.Text;
                profile.Save();
      }




All times are GMT -4. The time now is 10:56 PM.

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