Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Iain Martin 54 posts 98 karma points
    Dec 28, 2011 @ 13:02
    Iain Martin
    0

    Extending Membership/User properties

    I have created a user control to select a list of projects available from a bug tracking database and the project ID is assigned to a user. However, when I come to save the user, the property is not being saved. There are 2 issues to this:

    1. The selected value of the dropdown is not being retained and

    2. Even when manually updating the property in the immediate window, this value is not being saved in the database.

    I can see the property type in the database and it all ties up across the various tables for properties etc. My code behind is:;

    protected void Page_Load(object sender, EventArgs e)
    {
    Member myMember = Member.GetCurrentMember();

    if (Page.IsPostBack)
    {



    myMember.getProperty("clientBugNetProject").Value = ddlProjects.SelectedValue.ToString();
    myMember.Save();

    }
    else
    {
    List<Project> ProjectList = Project.GetAllProjects();

    ddlProjects.Items.Add(new ListItem("-- Select --", "-1"));

    foreach (Project P in ProjectList)
    {
    ddlProjects.Items.Add(new ListItem(P.Name, P.Id.ToString()));
    }

    if (ddlProjects.Items.Count > 0) { ddlProjects.SelectedValue = myMember.getProperty("clientBugNetProject").Value.ToString(); }
    }
    }

    Anyone got any bright ideas?

    Regards

    Iain

     

  • Paul 55 posts 76 karma points
    Dec 29, 2011 @ 06:33
    Paul
    0

    For #1 - Make sure the AutoPostBack property is set to true for the Dropdownlistbox

  • Iain Martin 54 posts 98 karma points
    Dec 29, 2011 @ 12:10
    Iain Martin
    0

    I tried the autopostback with no real success. However, I now appear to have another error in that it is not even registering the fact the member exists from the Member.getCurrentMember call, so it would appear to be getting worse!

    Has anyone done an extension to members with usercontrols that they have got to work?

    This is really frustrating as usercontrols for pages are so easy to create and implement, and unless I'm missing something here, I would have thought the membership page would work in exactly the same way.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 29, 2011 @ 14:42
    Tom Fulton
    0

    Hi Iain,

    Your code should work, that's really all you need to do.

    What version are you using?  There were some issues with GetCurrentMember recently that are fixed in 4.7.1.

    -Tom

  • Iain Martin 54 posts 98 karma points
    Jan 02, 2012 @ 11:22
    Iain Martin
    0

    Finally got this to work,

    For some reason that I can't quite figure out, the dropdowns and textboxes weren't populated by the Page_Load event so the property was always a blank or unselected value. Basically worked my way through the page lifecycyle and eventually found the controls were populated by the OnPreRender event, so I have put the save/update procedures in there and it appears to be working.

    It's a bit of a cludge, and not really the correct way to do it, but it does appear to be working okay for now though.

    Could this be a bug in the page lifecycle of Umbraco's membership page when using your own usercontrols?

    Regards

    Iain

     

     

Please Sign in or register to post replies

Write your reply to:

Draft