using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace CKS.FormsBasedAuthentication { class MembershipRequestGroupEditor : EditorPart { DropDownList ddlGroup; /// /// Editor Part Constructor /// public MembershipRequestGroupEditor() { LocalizedString resourceManager; resourceManager = new LocalizedString("FBAPackMembershipRequestWebPart"); this.ID = "GroupEditor"; this.Title = resourceManager.GetString("GroupEditor_Title"); this.Description = resourceManager.GetString("GroupEditor_Description"); } /// /// This is the standard method for adding controls to a web part. /// protected override void CreateChildControls() { ddlGroup = new DropDownList(); SPWeb web = SPControl.GetContextWeb(Context); SPGroupCollection groups = web.SiteGroups; for (int idx = 0; idx < groups.Count; idx++) { ddlGroup.Items.Add(groups[idx].Name); } this.Controls.Add(ddlGroup); } /// /// This method is called when the user applies changes and sets the property /// of the web part. /// /// True public override bool ApplyChanges() { EnsureChildControls(); MembershipRequestWebPart reg = this.WebPartToEdit as MembershipRequestWebPart; if (reg != null) { reg.GroupName = ddlGroup.Text; } return true; } /// /// This method is called when the user edits the web part by retrieving the data /// from the web part /// public override void SyncChanges() { EnsureChildControls(); MembershipRequestWebPart reg = this.WebPartToEdit as MembershipRequestWebPart; if (reg != null) { ddlGroup.Text = reg.GroupName; } } } }