SharePoint, Postback Event when using PeopleEditor

I'm using the SharePoint PeopleEditor to select a user and when the user is selected I want to populate a few fields with information about that user, I retrieve the data from AD. The problem I had was how do I make the PeopleEditor send a signal to my code that a value has been set?! There is no event on the PeopleEditor control which is fired when a value is set.

I first asked myself this question about a month ago, but as I have been unable to find an answer I added a button to my form which says "Retrieve Userinformation". This is not the normal way of UI design and during a demo for the customer today they made a remark about it, so I decided to take another look at this problem.

It took me almost an hour to realize that there is a property called AutoPostBack on some server controls. When you set this property a Postback will be generated when a value is set in the control. As you may understand from my lack of knowledge in this area ASP.NET UI design is not my primary competence, but in most cases I know enough to get the job done.

<SharePoint:PeopleEditor AutoPostBack="true" ID="peUser" runat="server" />

In the case of the PeopleEditor this means that when you type a username and click Check names (or hit enter) or use the Addressbook to select a user you will receive a generic postback, no specific event i raised by the page is reloaded. Therefore you can have code in your Page_Load which checks if a value has been selected and take some action.

string accountName = null;
if (peUser.ResolvedEntities.Count > 0)
{
    PickerEntity entity = (PickerEntity)peUser.ResolvedEntities[0];

    accountName = entity.Key;
    int pos = accountName.IndexOf('\\');
    accountName = accountName.Substring(pos + 1);

    // take some action based on accountName

}

In essence the AutoPostBack acts as an event generator which lets you perform an action when the value of the control is set.

Enjoy DDIBA~! Cool

Sharepoint, get username without domain or programmatically removing domain

CoolAssuming the user is returned in this format

domain\username you can do the following:

string userWithoutDomain = userName.Substring(userName.IndexOf('\\') + 1);

If the format is like this

username@domain then the following will work

string userWithoutDomain = user.Substring(0, user.IndexOf('@'));

Enjoy DDIBA~!

Useful Links 413

  1. Two Silverlight SDKs released – Bing and Facebook
  2. Bing Maps Silverlight Control Available!
  3. Blend SketchFlow project: from prototype to real screens?
  4. MVVM frameworks galore
  5. Magellan Quickstart
  6. Magellan and the Microsoft MVVM Toolkit
  7. Silverlight Organization Chart – Part 3 – The Node
  8. Silverlight Visual Tree Visualizer
  9. Skinning and Styling Silverlight Controls
  10. Silverlight out-of-browser and initParams
  11. Charting in Silverlight
  12. Filtered TextBox in Silverlight 3
  13. Should I use Silverlight or WPF for my new Enterprise Application?
  14. Hypnotizing Silverlight Splash Screen
  15. Change Date Picker Image in Silverlight 3
  16. Tweak Theme in Silverlight 3
  17. Creating a Custom Accordion Menu in Blend
  18. Telerik XAML Controls Q3 2009 Release
  19. Silverlight LOB: Validation (#2 – Annotations and Shared Classes)
  20. Inserting Text in TextBox using Silverlight 3
  21. Element to Element Binding in Silverlight 3.0
  22. Silverlight RIA Services
  23. The future of Moonlight
  24. Writing a (Completely Useless) Windows 7 Gadget using Silverlight
  25. Prism – MVVM – Silverlight gotcha’s
  26. A Virtual Input Keyboard

Useful Links 410

 

  1. New Video Tutorial: How to Create Custom RoutedEvents in Silverlight
  2. How to Get Your Silverlight Pages Indexed By Search Engine
  3. Silverlight 3′s New Application Extension Services
  4. Accessing Master-Detail Data through ADO.NET Data Service in a Silverlight Application (Part 2)
  5. New Silverlight Video Tutorial: How to use the Silverlight Toolkit’s WrapPanel to Create a Three Column ListBox
  6. Silverlight 3′s New {RelativeSource} Markup Extension
  7. Creating a Silverlight video player in Microsoft Expression Blend 3
  8. Implementing CoverFlow in Silverlight 3
  9. Skeleton for a Silverlight business application based on Ria Services and the Ria Services Class Library
  10. CodeFx – All in one package
  11. MVVM with Prism 101 – Part 6: Commands
  12. HyperLink Styling as Button in Silverlight 3
  13. http://silverlight.net/riaservices/ is Live!
  14. WriteableBitmap Extensions: Drawing Shapes
  15. Silverlight Wizard Control
  16. Designer v Xaml v Code
  17. Introducing Magellan
  18. All of My Video Tutorials in One Place (revisited)
  19. Subscribe to 62 Silverlight Twitter’ers.
  20. New Codeplex Silvelright Project! Silverlight StoryboardHelper

 

Useful Links 407

  1. Implementing CoverFlow in Silverlight 3
  2. Silverlight Toolkit on Web Platform Installer
  3. Debug Out Of Browser (OOB) Silverlight apps
  4. Update Out Of Browser (OOB) Silverlight apps
  5. Silverlight BringIntoView() extension method (with OnGotFocus behavior)
  6. Building N-Tier business applications with .NET RIA Services – Part I
  7. Grouping data in a Silverlight DataGrid
  8. Prism release for Silverlight 3.0
  9. Silverlight 3 Custom Sorting with Paging Support
  10. I Command MVVM
  11. MVVM with Prism 101 – Part 5b: ServiceLocator vs Dependency Injection
  12. VM Workshop: Model View ViewModel (MVVM) and the Presentation Model Pattern in 5 UI Platforms
  13. Thinking Outside the Box – Using Programmatic Animations in Silverlight
  14. Silverlight Communication: Three Ways to Connect
  15. Embed rich font in title
  16. Programming Silverlight with MVVM pattern using Prism
  17. Silverlight 3 – Enabling the Silverlight ‘Out of Browser’ Experience
  18. Silverlight: Creating Silverlight animations with code
  19. ZoomBoxPanel, adding full mouse support and animation to a WPF custom control: Part 3
  20. Quick tip: Snooping WPF application with elevated permissions
  21. 10 Expression Blend 3 Tutorials for Silverlight
  22. Magnifying glass effect
  23. Silver Draw – A Silverlight Based Collaboration White Board with Drawing and Chat
  24. Silverlight Organization Chart – Part 1 – Read XML file
  25. Silverlight Organization Chart – Part 2 – Calculations
  26. As the platform evolves, so do the workarounds [Better SetterValueBindingHelper makes Silverlight Setters better-er!]
  27. Silverlight From Zero
  28. Deep zooming on the fly

Useful Links 404

  1. Patterns-Based Silverlight Development Blog / Screencast Series Index
  2. Patterns-Based Silverlight Development – Part I – Getting Started
  3. Patterns-Based Silverlight Development – Part II – Repository and Validation
  4. Patterns-Based Silverlight Development – Part III – Pipeline Pattern
  5. Prism and Silverlight Screencasts on Channel 9
  6. Real-time list filtering with Silverlight, MVVM, and PagedCollectionView
  7. Rant: Silverlight – You Do Not Want the Blue Ball Loading Animation
  8. Reflection Shader for Silverlight 3
  9. Legally using non-standard fonts in Silverlight and Blend
  10. Silverlight Custom Content Control with Events

Useful Links 401

  1. MVVM with Prism 101 – Part 5: View-Model
  2. Patterns-Based Silverlight Development Blog / Screencast Series Index
  3. Patterns-Based Silverlight Development – Part I – Getting Started
  4. Patterns-Based Silverlight Development – Part II – Repository and Validation
  5. Patterns-Based Silverlight Development – Part III – Pipeline Pattern
  6. Patterns-Based Silverlight Development – Part IV – Service Layer
  7. Blendable MVVM: WCF and Asynch Data Sources
  8. My new home page, revised [Updated collection of great Silverlight/WPF Data Visualization resources!]
  9. New Silverlight Tooling Support in Visual Studio 2010 Beta 2
  10. Inserting a Silverlight Navigation and Slideshow into Your Web Page
  11. Making an object re-usable as a User Control in Blend
  12. Using Data Binding to share data in Blend
  13. Using Resources to share styling in Blend
  14. Using Behaviors to get things moving in Blend
  15. Eclipse Tools For Silverlight Now Available
  16. Custom Sorting and Paging on data
  17. Bulleted List in Silverlight
  18. New Video Tutorial: How to Create a Custom Silverlight Slider
  19. MVVM Light Toolkit V3 Alpha 1
  20. Drag Drop on List box
  21. XAML Power Toys Released for Visual Studio 2010
  22. Create a Login Screen in Silverlight 3
  23. Create a Login Window in WPF
  24. Caliburn v1 RTW for WPF, Silverlight 2.0 and 3.0!
  25. Rich Internet Applications: An Architect’s perspective on Silverlight 3
  26. Getting in-depth with SketchFlow
  27. Default and Custom Cursors in Silverlight
  28. Ribbit for Silverlight (R4SL) – Deep Dive Event
  29. WPF and Silverlight namescopes and DataContext differences
  30. Random Moving Rotator
  31. Silverlight and SharePoint 2010

Useful Links 398

  1. Silverlight FireStarter (Part 1 of 9): Event Kick Off
  2. Silverlight FireStarter (Part 2 of 9): Keynote
  3. Silverlight FireStarter (Part 3 of 9): Key Silverlight Scenarios
  4. Silverlight FireStarter (Part 4 of 9): Expression 3 Overview
  5. Silverlight FireStarter (Part 5 of 9): Sketch Flow
  6. Silverlight FireStarter (Part 6 of 9): Toolkit & Controls
  7. Silverlight FireStarter (Part 7 of 9): RIA Services
  8. Silverlight FireStarter (Part 8 of 9): Building Silverlight UIs with XAML Power toys
  9. Silverlight FireStarter (Part 9 of 9): Q&A Panel
  10. Finally a Simple MVVM in Silverlight
  11. Fun with CollectionViews
  12. How To: Silverlight grid hierarchy load on demand using MVVM and RIA services
  13. Dynamically setting initialization parameters in Silverlight application
  14. Changing the Mouse Icon graphic in Blend
  15. 10 shortcuts worth discovering in Expression Blend 3
  16. Sistr – Free open source rich typography tool for Silverlight
  17. Magellan – is a lightweight framework that makes it easy to build WPF navigationapplications
  18. XAML Tip: DataContext Comment
  19. Out-the-box controls in Blend
  20. Part 1: The Bootstrapper
  21. Part 2: The Shell
  22. Part 3: Regions
  23. Part 3b: View Injection and The Controller Pattern
  24. MVVM with Prism 101 – Part 4: Modules
  25. WPF samples now available at Code Gallery

Useful Links 395

  1. Creating Killer Animations in Code – Page 1
  2. Using Visual Studio 2010 for Silverlight development
  3. Silverlight (and WPF) Data Visualization classes unsealed [Silverlight Toolkit October 2009 release now available!]
  4. Creating buttons and using States in Blend
  5. Silverlight Quick Tip: How to get localized resources from RESX file in code behind
  6. The differences between Text Box and Text Block in Blend
  7. Silverlight Toolkit October 2009 Release
  8. Silverlight Hack of the Week – Auto Zoom
  9. Using the Stack Panel in Blend
  10. A Silverlight WidgetZone Control
  11. Patterns-Based Silverlight Development – Part I – Getting Started
  12. Patterns-Based Silverlight Development – Part II – Repository and Validation
  13. Patterns-Based Silverlight Development – Part III – Pipeline Pattern
  14. Adventures in MVVM – A Rails-Inspired ViewModel
  15. Microsoft Expression 3 – SketchFlow (Notes)
  16. Announcing Convexion – A New PowerPoint-to-Silverlight Add-in
  17. Silverlight Live Streaming service update
  18. Silverlight Toolkit adds DragDrop targets!
  19. Is Silverlight ready for the enterprise?
  20. Make your Silverlight 3 Applications Scream with GPU Acceleration
  21. Behaviours in Blend 3


Donate Me!

Please Help Us to Maintain This Site!

About the Author