Quantcast
Channel: eXpandFramework RSS
Viewing all articles
Browse latest Browse all 861

How to display the currently logged user name in the header bar near the Log Off Action on the Web

$
0
0
Here is another recent support thread update about personalizing your Web app:

To accomplish your task, consider one of the following solutions depending on your business requirements:

1. Default web template modification

Create a custom Default content template and add a new table cell with the following code to the markup (between cells containing the logo and header menu):

[ASPx]

...
<td>
<img src="Images/Logo.png" />
</td>
<td class="width100"></td>
<td><%= DevExpress.ExpressApp.SecuritySystem.CurrentUserName %></td>
<td>
<div id="xafHeaderMenu" class="xafHeaderMenu" style="float: right;">
...
</td>
...
2. Inherit from the standard HeaderMenuController class
Override its GetActionContainerCaption method (and optionally the GetActionContainerImageUrl method) as shown in our XCRM demo ("C:\Users\Public\Documents\DevExpress Demos 1X.X\Components\eXpressApp Framework\XCRM\CS\XCRM.Module.Web\CustomHeaderMenuController.cs").



3. Customizing the "My Details" Action caption directlyYou can customize the standard MyDetailsController class in the following manner (optionally, customize the corresponding navigation item):
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Security;
using DevExpress.ExpressApp.SystemModule;

namespace MainDemo.Module {
    public class WindowController1 : WindowController {
        public WindowController1() {
            TargetWindowType = WindowType.Main;
        }
        protected override void OnActivated() {
            base.OnActivated();
            string ActionItemId = "MyDetails";
            Frame.GetController<MyDetailsController>().Actions[ActionItemId].Caption = SecuritySystem.CurrentUserName;
            //Optionally, customize the corresponding navigation item.
            Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.Items.Find(
                ActionItemId, ChoiceActionItemFindType.Recursive, ChoiceActionItemFindTarget.Leaf
            ).Caption = SecuritySystem.CurrentUserName;
        }
    }
}

See Also:
Refer to the following help topics for more details on the demonstrated approaches:
How to: Customize an ASP.NET Template.eXpressApp Framework > Concepts > Extend Functionality > Customize Controllers and Actions
WebApplication
 > SwitchToNewStyle,
ASP.NET Web Application's Appearance

I personally like the second option the most, what about you?

Viewing all articles
Browse latest Browse all 861

Trending Articles