Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The only inbuilt method of customising the output is the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginname.formatstring.aspx" rel="nofollow"><code>LoginName.FormatString</code></a> property, unfortunately all this allows is for you to provide a format string which the username gets embedded into, such as "Welcome, DOMAIN\NAME" rather than just "DOMAIN\NAME".</p> <p>The only option I can see is to re-implement the LoginName control, either wholesale or by inheriting from <code>LoginName</code> and re-implementing the <code>RenderContents</code> method to format the username appropriately. From Reflector, the current code (for .net 2.0) for this is:</p> <pre><code>Protected Friend Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) Dim userName As String = Me.UserName If Not String.IsNullOrEmpty(userName) Then userName = HttpUtility.HtmlEncode(userName) Dim formatString As String = Me.FormatString If (formatString.Length = 0) Then writer.Write(userName) Else Try writer.Write(String.Format(CultureInfo.CurrentCulture, formatString, New Object() { userName })) Catch exception As FormatException Throw New FormatException(SR.GetString("LoginName_InvalidFormatString"), exception) End Try End If End If End Sub </code></pre> <p><code>UserName</code> is a <code>Friend ReadOnly</code> property of the LoginName class which, via another internal class called LoginUtil gets the username from <code>HttpContext.Current.User</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload