I have an .aspx page using a login control with custom authentication. I was wondering if it's possible to have a "Welcome [FirstName] [LastName]" message using the LoginName control instead of the [UserName] that is accessed by default.
I'm thinking of storing these info in the Session object if it's not possible.
Thanks!
-
You'll need to override the
RenderContentsmethod or make your own LoginName control. Something like this will do the trick:protected override void RenderContents(HtmlTextWriter writer) { if (string.IsNullOrEmpty(Profile.FullName)) return; nameToDisplay = HttpUtility.HtmlEncode(Profile.FullName); string formatExpression = this.FormatString; if (formatExpression .Length == 0) { writer.Write(nameToDisplay); } else { try { writer.Write(string.Format(CultureInfo.CurrentCulture, formatExpression, new object[1] { nameToDisplay }); } catch (FormatException exception) { throw new FormatException("Invalid FormatString", exception1); } } }Also, see here for a brief article on working with LoginName.
Leon Tayson : I'm not using the default ASP.NET providers and not using Profile also. I settled with storing the user's full name in the session object instead. Thanks! -
First of all, see http://stackoverflow.com/questions/620118/personal-names-in-a-global-application-what-to-store. Even if your site is limited to the US, I'm pretty sure I've seen some foreigners around here.
-
You could use the FormatString property to set the welcome message to any string you want. When combined with expression builders (e.g. <%$ expressionPrefix: expressionValue %>) you would have a flexible way to define output.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.