PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/SPALM.SharePointSoftwareFactory/Snippets/CSharp/SharePoint Software Factory 2010/ListItems/Get the value of a user field from a list item.snippet

#
Unknown | 65 lines | 65 code | 0 blank | 0 comment | 0 complexity | 58f4f16fc39352d4ea9bbb91ac3e973e MD5 | raw file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3. <CodeSnippet Format="1.0.0">
  4. <Header>
  5. <SnippetTypes>
  6. <SnippetType>Expansion</SnippetType>
  7. </SnippetTypes>
  8. <Title>Get the value of a user field from a list item</Title>
  9. <Author>Ayman El-Hattab http://ayman-elhattab.blogspot.com
  10. </Author>
  11. <Description>
  12. </Description>
  13. <HelpUrl>http://SPCodeSnippets.codeplex.com</HelpUrl>
  14. <Shortcut>
  15. </Shortcut>
  16. </Header>
  17. <Snippet>
  18. <Declarations>
  19. <Object Editable="true">
  20. <ID>userValue</ID>
  21. <ToolTip>SPFieldUserValue</ToolTip>
  22. <Default>userValue</Default>
  23. <Function>
  24. </Function>
  25. <Type>SPFieldUserValue</Type>
  26. </Object>
  27. <Object Editable="true">
  28. <ID>item</ID>
  29. <ToolTip>SPListItem</ToolTip>
  30. <Default>item</Default>
  31. <Function>
  32. </Function>
  33. <Type>SPListItem</Type>
  34. </Object>
  35. <Object Editable="true">
  36. <ID>web</ID>
  37. <ToolTip>SPWeb</ToolTip>
  38. <Default>web</Default>
  39. <Function>
  40. </Function>
  41. <Type>SPWeb</Type>
  42. </Object>
  43. <Literal Editable="true">
  44. <ID>UserName</ID>
  45. <ToolTip>UserName</ToolTip>
  46. <Default>UserName</Default>
  47. <Function>
  48. </Function>
  49. </Literal>
  50. <Object Editable="true">
  51. <ID>user</ID>
  52. <ToolTip>SPUser</ToolTip>
  53. <Default>user</Default>
  54. <Function>
  55. </Function>
  56. <Type>SPUser</Type>
  57. </Object>
  58. </Declarations>
  59. <Code Language="csharp"><![CDATA[
  60. SPFieldUserValue $userValue$ = new SPFieldUserValue($web$, $item$["$UserName$"].ToString());
  61. SPUser $user$ = $userValue$.User;
  62. ]]></Code>
  63. </Snippet>
  64. </CodeSnippet>
  65. </CodeSnippets>