Archive

Archive for the ‘c#’ Category

Custom UserProfile Property Class for SharePoint

June 10th, 2009 Michael Bell 2 comments

I had a recent project where I needed to bind to the properties in the sharepoint userprofile collection. I found the easiest method was to create an object that contains properties that use the PropertyConstant enumerator to return values from the UserProfile object. It may not be the cleanest, but it let me bind a list of these to a grid, which was what I needed to do.

[Serializable]
    public class UserProfilePropertyObject
    {
        private UserProfile _userProfile = null;

        public UserProfilePropertyObject(UserProfile userProfile)
        {
            _userProfile = userProfile;
        }

        public string FullName
        {
            get { return LastName + ", " + FirstName; }
        }
        public string AccountName
        {
            get
            {
                return (_userProfile[PropertyConstants.AccountName].Value ?? "N/A").ToString();
            }
        }
        public string FirstName
        {
            get
            {
                return (_userProfile[PropertyConstants.FirstName].Value ?? "N/A").ToString();
            }
        }
        public string LastName
        {
            get
            {
                return (_userProfile[PropertyConstants.LastName].Value ?? "N/A").ToString();
            }
        }
        public string Username
        {
            get
            {
                return (_userProfile[PropertyConstants.UserName].Value ?? "N/A").ToString();
            }
        }
        public string WorkPhone
        {
            get
            {
                return (_userProfile[PropertyConstants.WorkPhone].Value ?? "N/A").ToString();
            }
        }
        public string Office
        {
            get
            {
                return (_userProfile[PropertyConstants.Office].Value ?? "N/A").ToString();
            }
        }
        public string Department
        {
            get
            {
                return (_userProfile[PropertyConstants.Department].Value ?? "N/A").ToString();
            }
        }
        public string Title
        {
            get
            {
                return (_userProfile[PropertyConstants.Title].Value ?? "N/A").ToString();
            }
        }
        public string Manager
        {
            get
            {
                return (_userProfile[PropertyConstants.Manager].Value ?? "N/A").ToString();
            }
        }
        public string AboutMe
        {
            get
            {
                return (_userProfile[PropertyConstants.AboutMe].Value ?? "N/A").ToString();
            }
        }
        public string PersonalSite
        {
            get
            {
                return (_userProfile[PropertyConstants.PersonalSpace].Value ?? "N/A").ToString();
            }
        }
        public string Picture
        {
            get
            {
                return (_userProfile[PropertyConstants.PictureUrl].Value ?? "N/A").ToString();
            }
        }
        public string Website
        {
            get
            {
                return (_userProfile[PropertyConstants.WebSite].Value ?? "N/A").ToString();
            }
        }
        public string PublicSiteRedirect
        {
            get
            {
                return (_userProfile[PropertyConstants.PublicSiteRedirect].Value ?? "N/A").ToString();
            }
        }
        public string DottedLineManager
        {
            get
            {
                return (_userProfile[PropertyConstants.Dottedline].Value ?? "N/A").ToString();
            }
        }
        public string Responsibilities
        {
            get
            {
                return (_userProfile[PropertyConstants.Responsibility].Value ?? "N/A").ToString();
            }
        }
        public string Skills
        {
            get
            {
                return (_userProfile[PropertyConstants.Skills].Value ?? "N/A").ToString();
            }
        }
        public string PastProjects
        {
            get
            {
                return (_userProfile[PropertyConstants.PastProjects].Value ?? "N/A").ToString();
            }
        }
        public string Interests
        {
            get
            {
                return (_userProfile[PropertyConstants.Interests].Value ?? "N/A").ToString();
            }
        }
        public string Schools
        {
            get
            {
                return (_userProfile[PropertyConstants.School].Value ?? "N/A").ToString();
            }
        }
        public string SIPAddress
        {
            get
            {
                return (_userProfile[PropertyConstants.SipAddress].Value ?? "N/A").ToString();
            }
        }
        public string Birthday
        {
            get
            {
                return (_userProfile[PropertyConstants.Birthday].Value ?? "N/A").ToString();
            }
        }
        public string MySiteUpgrade
        {
            get
            {
                return (_userProfile[PropertyConstants.MySiteUpgrade].Value ?? "N/A").ToString();
            }
        }
        public string DontSuggestList
        {
            get
            {
                return (_userProfile[PropertyConstants.DontSuggestList].Value ?? "N/A").ToString();
            }
        }
        public string HireDate
        {
            get
            {
                return (_userProfile[PropertyConstants.HireDate].Value ?? "N/A").ToString();
            }
        }
        public string LastColleagueAdd
        {
            get
            {
                return (_userProfile[PropertyConstants.LastColleagueAdded].Value ?? "N/A").ToString();
            }
        }
        public string OutlookWebAccessURL
        {
            get
            {
                return (_userProfile[PropertyConstants.OutlookWebAccessUrl].Value ?? "N/A").ToString();
            }
        }
        public string Assistant
        {
            get
            {
                return (_userProfile[PropertyConstants.Assistant].Value ?? "N/A").ToString();
            }
        }
        public string WorkEmail
        {
            get
            {
                return (_userProfile[PropertyConstants.WorkEmail].Value ?? "N/A").ToString();
            }
        }
        public string MobilePhone
        {
            get
            {
                return (_userProfile[PropertyConstants.CellPhone].Value ?? "N/A").ToString();
            }
        }
        public string Fax
        {
            get
            {
                return (_userProfile[PropertyConstants.Fax].Value ?? "N/A").ToString();
            }
        }
        public string HomePhone
        {
            get
            {
                return (_userProfile[PropertyConstants.HomePhone].Value ?? "N/A").ToString();
            }
        }
        public Guid ID
        {
            get
            {
                return _userProfile.ID;
            }
        }

    }
Categories: MOSS, SharePoint 2007, c# Tags:

Validation against Controls outside of the current NamingContainer

April 21st, 2009 Michael Bell 1 comment

I had a situation where I needed to do this recently. I googled of course, and came up with an overloaded FindControl method. I implemented this in my code, and all seemed well. UNTIL… came the time to get the data posted from my control. I had controls nested in a UserControl, and that usercontrol nested within a FormView. When the postback occurred, I was able to retrieve all values from controls directly in the formview but none from within the controls inside my usercontrol. A buddy of mine helped me out on this, and believe me.. it was no fun tracking down. the values “not being posted” was actually a flaw in the FindControl method override. Please use this piece of code in the naming container that your validators reside, if they in fact need to validate against controls outside:

protected override Control FindControl(string id, int pathOffset)
{
Control c = base.FindControl(id, pathOffset);
if (c != null)
return c;
return FindControl(Page, id);
}
public Control FindControl(Control parent, string id)
{
Control recurse;
if (parent.ID == id)
{
return parent;
}
foreach (Control child in parent.Controls)
{
recurse = FindControl(child, id);
if (recurse != null)
{
return recurse;
}
}
return null;
}
Categories: ASP.NET, Uncategorized, Whatever, c# Tags:

TimePicker Update

March 7th, 2009 Michael Bell No comments

As requested, I added functionality to the time picker to allow the up and down arrows on the keyboard to increase and decrease the values in the hours, minutes, seconds, and toggle the AM/PM box. I’ve also made the semi-colon seperators unfocusable.

Categories: ASP.NET, ASP.NET TimePicker Control, c# Tags:

ASP.NET TimePicker Documentation

February 27th, 2009 Michael Bell 7 comments

I finally got some documentation together for the TimePicker using Sandcastle and Docsite. For some reason I couldn’t get it to work as a subfolder or virtual directory of this site, so I have it on a funky port. Regardless, here is the link:

ASP.NET TimePicker Documentation

Categories: .NET TimePicker, ASP.NET, c# Tags: