Update MemberType property based on dropdown list select value
I have created a property under
a MemberType called "testField" which is using a custom DataType
dropdown list with 2 values in it (Employee and Subcontractor). I would
like for a user to be able to select one, submit a form and to store
their selection under this property, but I can't seem to figure it out.
Is it possible to do this whilst being able to change their selection manually in the back end?
protectedvoidBtnSubmitClick(object sender,EventArgs e) { var redirecturl =Settings.Url;
// Check the user isn't already registered if(Member.GetMemberFromEmail(Helpers.GetSafeHtml(tbEmail.Text))==null&Member.GetMemberFromLoginName(Helpers.GetSafeHtml(tbLoginName.Text))==null) { // Set the member type and group var mt =MemberType.GetByAlias(MembershipHelper.ForumUserRoleName); var addToMemberGroup =MemberGroup.GetByName(MembershipHelper.ForumUserRoleName);
//create a member var m =Member.MakeNew(Helpers.GetSafeHtml(tbName.Text), mt,new umbraco.BusinessLogic.User(0));
//var mstatus = new MembershipCreateStatus(); //var mp = Membership.CreateUser(tbName.Text, tbPassword.Text, tbEmail.Text, string.Empty, string.Empty, true, out mstatus);
// Set the other properties m.Email=Helpers.GetSafeHtml(tbEmail.Text); m.LoginName=Helpers.GetSafeHtml(tbLoginName.Text); m.Password=Helpers.GetSafeHtml(tbPassword.Text); // Add 0 Karma to user, helps us later in the site m.getProperty("forumUserKarma").Value=0; m.getProperty("forumUserAllowPrivateMessages").Value=1; m.getProperty("forumUserLastPrivateMessage").Value=DateTime.Now;
// Take selected dropdown value and store m.getProperty("testField").Value= tbOrganisation;
//##### Manual Member Authorisation ##### // If this is not enabled, mark the member as authorised if(!Settings.ManuallyAuthoriseNewMembers) { m.getProperty("forumUserIsAuthorised").Value=1; }
m.AddGroup(addToMemberGroup.Id);
//Save member m.Save();
//Generate member Xml Cache m.XmlGenerate(newSystem.Xml.XmlDocument());
if(!Settings.ManuallyAuthoriseNewMembers) { //Login the user so they can be redirected to their profile page FormsAuthentication.SetAuthCookie(tbLoginName.Text,false); } else { redirecturl =string.Concat(CurrentPageAbsoluteUrl,"?m=", library.GetDictionaryItem("NotifiedWhenAccountAuth")); }
// If admins wants email notification, then send it here if(Settings.EmailAdminOnNewMemberSignUp) { SendAdminNotification(m); } } else { redirecturl =string.Concat(CurrentPageAbsoluteUrl,"?m=", library.GetDictionaryItem("UserAlreadyExists")); }
// Now redirect to the correct page Response.Redirect("/discuss-it");
Update MemberType property based on dropdown list select value
I have created a property under a MemberType called "testField" which is using a custom DataType dropdown list with 2 values in it (Employee and Subcontractor). I would like for a user to be able to select one, submit a form and to store their selection under this property, but I can't seem to figure it out.
Is it possible to do this whilst being able to change their selection manually in the back end?
Here's my code...
ASCX
CS
Nevermind, fixed it myself :)
I had to change
m.getProperty("testField").Value= tbOrganisation;
to
m.getProperty("testField").Value = tbOrganisation.SelectedValue;
And also the value IDs needed to match those in my DataType prevalues.
is working on a reply...