There Really Is an Authentication Button Class

I got in an argument today over the phone with a co-worker I used to work with that there was no AuthenticationButton Class. Actually, there is a sealed AuthenticationButton class that inherits from System.Web.UI.Control class, the System.Web.UI.INamingContainer interface, and the Microsoft.SharePoint.WebControls. IDesignTimeHtmlProvider.

To be honest, I only used it in SharePoint 2003, but it doesn’t appear to be deprecated in SharePoint 2007, so I am on the ball. So, how do you use it? Well, it is pretty easy, because its like adding any control to a SharePoint WebPart.

The first that you have to do when creating a Windows SharePoint Services custom component that makes use of the AuthenticationButton class to make the appropriate references. The AuthenticationButton class exists in the Microsoft.SharePoint.WebPartPages namespace, so make the reference:

[csharp]
using Microsoft.SharePoint.WebPartPages;
[/csharp]

Then, you have to setup your class to use the Authentication Button, so delcare it:

[csharp]
private AuthenticationButton SharePointAuthButton;
[/csharp]

In your CreateChildControls() method, create a new AuthenticationButton, and then add it by using the add method out of the controls class.

[csharp]
protected override void CreateChildControls()
{
SharePointAuthButton = new AuthenticationButton();
Controls.Add(SharePointAuthButton);
}
[/csharp]

Its not real fancy, but I am happy because I was right :-) It only happens far and few between!

Share

Leave a Reply

Your email address will not be published. Required fields are marked *