SPListEvent.UserDisplayName Property
NOTE: This API is now obsolete.
Gets the display name of the user whose action triggers the event.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<ObsoleteAttribute("Use V3 style events")> _
Public ReadOnly Property UserDisplayName As String
Get
'Usage
Dim instance As SPListEvent
Dim value As String
value = instance.UserDisplayName
[ObsoleteAttribute("Use V3 style events")]
public string UserDisplayName { get; }
Property Value
Type: System.String
A string that contains the name of the user.
Examples
The following code example uses the UserDisplayName property to display information within a specified column of a document library list when changes are made to files.
Public Class EventHandler
Implements IListEventSink
Public Sub OnEvent(listEvent As Microsoft.SharePoint.SPListEvent)
If Not listEvent.Type = SPListEventType.Update Then
Return
End If
Dim site As SPWeb = listEvent.Site.OpenWeb()
Dim file As SPFile = site.GetFile(listEvent.UrlAfter)
Dim item As SPListItem = file.Item
Dim userName As String = listEvent.UserDisplayName
Dim report As String = userName + " modified at " +
file.TimeLastModified
item("Column_Title") = report
item.Update()
End Sub 'OnEvent
End Class 'EventHandler
public class EventHandler : IListEventSink
{
public void OnEvent(SPListEvent oListEvent)
{
if (! (oListEvent.Type == SPListEventType.Update))
return;
using(SPWeb oWebsite = oListEvent.Site.OpenWeb())
{
SPFile oFile = oWebsite.GetFile(oListEvent.UrlAfter);
SPListItem oItem = oFile.Item;
string strUserName = oListEvent.UserDisplayName;
string strReport = strUserName + " modified at " +
oFile.TimeLastModified;
oItem["Column_Title"] = strReport;
oItem.Update();
}
}
}
Note
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.