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?
Add custom tab to user properties in SPAdmin
-
- Posts: 105
- Joined: Wed Oct 17, 2012 4:20 pm
-
- Posts: 105
- Joined: Wed Oct 17, 2012 4:20 pm
Re: Add custom tab to user properties in SPAdmin
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.
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.
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Add custom tab to user properties in SPAdmin
It Is possible. We will provide a code snippet shortly.
John Morris
Sr. Software Architect
SoftPro
Sr. Software Architect
SoftPro
-
- Posts: 1377
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: Add custom tab to user properties in SPAdmin
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.
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.
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:
Select sequence of events for: Open dialog
Select sequence of events for: OK or Apply if IsDirty is true
- 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();
}
...
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
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...
}
- OnInitialize()
- OnReadValues()
Code: Select all
// Use button handler to set the IsDirty flag.
private void button1_Click(object sender, EventArgs e)
{
this.IsDirty = true;
}
- OnValidateValues()
- OnCommit()
- OnReadValues()
Bob Richards, Senior Software Developer, SoftPro