The PeopleEditor Class and the Visibility Attribute

When doing custom development for MOSS 2007 or WSS 3.0, the PeopleEditor class can come in handy. However, it seems that it begins misbehaving when the the Visibility attribute is changed from its default value of true. Recently, I had the need to make it disappear and reappear depending on certain conditions in a custom form that was developed and I ran into this problem. The work around simply involves using a display style attribute. To make control invisible, set the display style attribute value to none. To make the control visible again, set the display style attribute value back to block.

Here is a sample C# method that I used to make this happen:


private void SetPeopleEditorVisibility(ref PeopleEditor pe, bool visible)
{
  if (pe.Style.Keys.Count > 0 && pe.Style["display"] != null)
  {
    pe.Style.Remove("display");
  }
  if (visible)
  {
    pe.Style.Add("display", "block");
  }
  else
  {
    pe.Style.Add("display", "none");
  }
}

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
This entry was posted in Microsoft Office, Sharepoint Server, Web Development, Windows Sharepoint Services and tagged , , , , , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>