Add custom tab to user properties in SPAdmin

Discussions related to custom development with Select.
Post Reply
chris.brady
Posts: 105
Joined: Wed Oct 17, 2012 4:20 pm

Add custom tab to user properties in SPAdmin

Post by chris.brady »

Is there a way to add another tab or two of our own to the user properties page in SPAdmin?

If so, do you have a snippet for how that might be done?
2019-01-22_8-00-51.jpg
2019-01-22_8-00-51.jpg (52.74 KiB) Viewed 1883 times
chris.brady
Posts: 105
Joined: Wed Oct 17, 2012 4:20 pm

Re: Add custom tab to user properties in SPAdmin

Post by chris.brady »

I got a notification that there was a reply to this thread, and saw Bob had said it wasn't possible, but that comment appears to have been deleted.

If that means it's possible and you're working on a snippet, awesome! However, if it isn't possible in the current architecture, please let me know so I can pass along to my higher ups.
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Add custom tab to user properties in SPAdmin

Post by John Morris »

It Is possible. We will provide a code snippet shortly.
John Morris
Sr. Software Architect
SoftPro
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Add custom tab to user properties in SPAdmin

Post by BobRichards »

It turns out that new property pages can be added quite easily. Create a shell package and add a User Control to the project then follow the list of changes below.
  • Add a Guid attribute. (This requires adding "System.Runtime.InteropServices" namespace.)
  • Add DesignerCategory attribute so the solution explorer displays the appropriate icon.
  • Change the inherited class from "UserControl" to "PropertyPage". (The new base class requires adding "SoftPro.Select.Shell" namespace.)
  • Change the signature of the user control constructor to an override of OnInitialize() as shown.
  • Add implementation bodies to necessary override methods.

Code: Select all

[Guid("eb65528c-84aa-4fbb-8e6c-b3bd09db29fe")]
[DesignerCategory("Designer")]
public partial class AnotherTab : PropertyPage
{
    protected override void OnInitialize()
    {
        base.OnInitialize();
        base.Title = "AnotherTab";

        InitializeComponent();
    }

    ...
Finally, add a ProvidePropertyPage attribute so Select can find it and combine it with the other property pages that have been registered to go with the dialog. The final integer in the attribute is the priority. It sets the order of the tab in the container. You should use high numbers so you new pages fall at the end. If you use a lower number, you may successfully squeeze a page in where you want it, but SoftPro reserves the right to add additional tabs and your tab could move - which might prove disorienting to your end user.

Additionally, you might wonder how to determine the target name to use in your attribute (ISecurityUser). The short answer is will have to ask us.

Code: Select all

[ProvidePropertyPage(typeof(AnotherTab), @"User AnotherTag Property Page", typeof(ISecurityUser), 1000)]
[Guid(PackageGuidString)]
partial class MyPackage : Package
At this point the page would be rendered but it doesn't really do much. Refer to the SDK for PropertyPage and you will see many methods to override to add your desired behavior. Below are examples of useful overrides:

Code: Select all

    /// <summary>
    /// Called when the objects should be read into the property page.
    /// Called before dialog opens after OnInitialize() exits.
    /// </summary>
    protected override void OnReadValues()
    {
        base.OnReadValues();

        // User code...
    }

    /// <summary>
    /// Validate user input on "Allow" and "OK" and return true if no errors.
    /// </summary>
    /// <returns></returns>
    protected override bool OnValidateValues()
    {
        // User code...

        // Allow changes.
        return true;
    }

    /// <summary>
    /// Called when user presses "Allow" and "OK" after OnValidateValue() if values pass validation.
    /// Save data.
    /// </summary>
    protected override void OnCommit()
    {
        // User code...
    }
Select sequence of events for: Open dialog
  1. OnInitialize()
  2. OnReadValues()
If you have set the IsDirty flag then when the OK or Apply buttons are pressed, you will have a change to validate then save changes.

Code: Select all

    // Use button handler to set the IsDirty flag.
    private void button1_Click(object sender, EventArgs e)
    {
        this.IsDirty = true;
    }
Select sequence of events for: OK or Apply if IsDirty is true
  1. OnValidateValues()
  2. OnCommit()
  3. OnReadValues()
Bob Richards, Senior Software Developer, SoftPro
Post Reply