Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2011, 02:11 PM
Registered User
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default LoginName to include email address

Imar,

I have the LoginName as part of the footer of the MasterPage.

For test purposes, LoginName1.FormatString = "Demo: Welcome, {0}" is in the Page_Load event of the MasterPage.

LoginName1.FormatString = "Demo: Welcome, " + Context.User.Identity.Name also seems to work displaying "Demo: Welcome, Dave" as an example.

I would like to include the email address of the logged in person so that it would display "Demo: Welcome, Dave<xxxxx,@yy.zz>".

Below is what I tried. This value seems to populate if I assign it to a textbox of a page, but doesn't seem to work on the MasterPage footer.

LoginName1.FormatString = "Demo: Welcome, " + Context.User.Identity.Name + "<" + Membership.GetUser().Email().ToString + ">"
 
Old April 1st, 2011, 03:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I am not exactly sure where you are calling this in the Master Page, but it could be that you're too late. In addition, you're not really setting a FormatString anymore (e.g. no {0}) so there's not much to Format for ASP.NET.

If you are already building up the entire welcome text, drop the LoginName control and simply assign the text to a Label instead:

Code:
 
myLabel.Text = "Demo: Welcome, " + Context.User.Identity.Name + "<" + Membership.GetUser().Email().ToString + ">"
And another thing: could it be that it *does* work but you're not seeing the e--mail address?

<[email protected]> will be interpreted as an unknown tag by the browser and thus ignored.

Try "%gt;" and "&lt;" instead.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 1st, 2011, 11:47 AM
Registered User
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default LoginName to include email address

You were right, it does work. All that was needed was to use "&lt;" and "&gt;". Such an easy fix with all the time spent trying other approaches that didn't work.

Imar, your the best.

Thanks again.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Valid Email Address...... muskaanbajaj VB.NET 1 November 22nd, 2005 11:38 AM
Validating an email address Dave Brown Beginning PHP 2 March 31st, 2005 11:14 AM
How to validate email address crmpicco Javascript How-To 2 February 16th, 2005 10:56 AM
Validate Email address richardtr BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 6 November 23rd, 2004 01:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.