[DevExpress Support Team: CLONED FROM T321618: Web - How to display the currently logged user name and image in the header bar near the Log Off Action]
Hi Konstantin,
I have follow the blog on http://dennisgaravsky.blogspot.co.id/2016/12/displaying-currently-logged-user-name.html
but it only show user name, no image, whats wrong ? not even after i reduce photo size (see the picture attached)
this is my security user class
using System;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
namespace ELS2018.Module.BusinessObjects
{
[DefaultProperty("UserName"), XafDisplayName("Limited User")]
[CurrentUserDisplayImage("Photo")]
//[ImageName("BO_Contact")]
//[DefaultProperty("DisplayMemberNameForLookupEditorsOfThisType")]
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
//[Persistent("DatabaseTableName")]
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
public class SecurityUser : PermissionPolicyUser
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
public SecurityUser(Session session)
: base(session)
{
}
private Branch company;
[Association("Branch-Users")]
public Branch Company
{
get { return company; }
set { SetPropertyValue("Company", ref company, value); }
}
private String userserver;
[XafDisplayName("Server")]
public String UserServer
{
get { return userserver; }
set { SetPropertyValue("UserServer", ref userserver, value); }
}
private String userdatabase;
[XafDisplayName("Database")]
public String UserDatabase
{
get { return userdatabase; }
set { SetPropertyValue("UserDatabase", ref userdatabase, value); }
}
public virtual MediaDataObject Photo { get; set; }
[Association("Users-Customers")]
public XPCollection<Customer> Customers
{
get { return GetCollection<Customer>("Customers"); }
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
}
//private string _PersistentProperty;
//[XafDisplayName("My display name"), ToolTip("My hint message")]
//[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
//[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
//public string PersistentProperty {
// get { return _PersistentProperty; }
// set { SetPropertyValue("PersistentProperty", ref _PersistentProperty, value); }
//}
//[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
//public void ActionMethod() {
// // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
// this.PersistentProperty = "Paid";
//}
}
}
Konstantin B (DevExpress) >
Please run the Model Editor for the ASP.NET module or application project and ensure that the IModelApplicationWeb.CurrentUserDisplayMode property is set to CaptionAndImage.
Additionally, if you store the model differences in the database, ensure that this setting is not overridden accidentally at the database level. If this does not help, would you please create a separate ticket and attach a sample project that shows this issue?
PS: the virtual modifier is not required for the Photo property in an XPO persistent class. An example from the blog you are referring to is for Entity Framework.
ADE AAN WIRAMA >
I did choose CaptionAndImage, but its not working. I'm sure its not overridden at database level. (see Screenshot_27)