How can I display the email address and account type in my page?Once I clicked the Account menu I want to display the account name, type of account and email address of the current user. All of those are configured in ASP.net configuration(administer website)
.NET 2.0 provides APIs for accessing everything in a configuration file. If you want to access Config File Mail Settings Programmatically, you can use
System.Net.Configuration.MailSettingsSectionGroup, for
example:
If
youhave
enabled membership and role
management for your ASP.Net App, you can use
Roles.GetRolesForUser method to get a list of the roles that the currently logged-on user is in:
string[] rolesArray=Roles.GetRolesForUser();
About Username and Email Address, please refer to Dave's replay.
paulalvin
Member
229 Points
246 Posts
how to display role type email address found in ASP.net configuration
Apr 04, 2012 05:14 AM|LINK
How can I display the email address and account type in my page?Once I clicked the Account menu I want to display the account name, type of account and email address of the current user. All of those are configured in ASP.net configuration(administer website)
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: how to display role type email address found in ASP.net configuration
Apr 06, 2012 07:10 AM|LINK
.NET 2.0 provides APIs for accessing everything in a configuration file. If you want to access Config File Mail Settings Programmatically, you can use System.Net.Configuration.MailSettingsSectionGroup, for example:
Then you can display these values on the page.
Feedback to us
Develop and promote your apps in Windows Store
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: how to display role type email address found in ASP.net configuration
Apr 06, 2012 08:32 AM|LINK
Use the membership API to get the current user. Eg:
MembershipUser user = Membership.GetUser();
string userName = user.UserName;
string email = user.Email
What do you mean by account type? The membership user doesn't have a type; is this a role of some sort?
paulalvin
Member
229 Points
246 Posts
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 12:46 AM|LINK
Account type, for example he belongs to the admininstrators I want to diplay the account type as admin that have all the access in the page
paulalvin
Member
229 Points
246 Posts
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 01:23 AM|LINK
I want to display these when I clicked the account in the webpage
Username:
Email Address:
Account Type:
How can I display these things?thanks
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 02:17 AM|LINK
If you have enabled membership and role management for your ASP.Net App, you can use Roles.GetRolesForUser method to get a list of the roles that the currently logged-on user is in: string[] rolesArray=Roles.GetRolesForUser();
About Username and Email Address, please refer to Dave's replay.
For more membership and roles API, please read membership class and Roles class
Thanks,
Feedback to us
Develop and promote your apps in Windows Store
paulalvin
Member
229 Points
246 Posts
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 04:26 AM|LINK
public partial class accountinfo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lblType.Text = Session["RoleName"].ToString(); } }why this code doesnt work?
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 04:51 AM|LINK
Where you store value to the session variables? First, please save the values to a session variable: Session["RoleName"] = "Your Role Name";
Then
if(Session["RoleName"]!=null)
{
lblType.Text = Session["RoleName"].ToString();
}
else
{
lblType.Text ="Sorry,the value you want does not exist!";
}
Feedback to us
Develop and promote your apps in Windows Store
paulalvin
Member
229 Points
246 Posts
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 04:58 AM|LINK
This code works
public partial class accountinfo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var user = Membership.GetUser(); var roles = System.Web.Security.Roles.GetRolesForUser(user.UserName); if (roles.Length > 0) { lblRoles.Text = string.Format("You are a/n {0}", roles[0]); } } }But, what if I want to display also the email add?and those included in the add user form?
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: how to display role type email address found in ASP.net configuration
Apr 10, 2012 05:17 AM|LINK
Add lblEmailAdd.Text = user.Email; to your if block.
Feedback to us
Develop and promote your apps in Windows Store