user comment display on asp.net page
I have an asp.ne开发者_如何学Got page which uses the asp membership control. I want to use the user comment field to hold an additional piece of information. I'm creating the user via the Web Site Administration Tool.
So how would I access the comment field and write it to the page?
Ok I'm not totally mad (well maybe but that's my state of mind!). the comment field lives in the aspnet_Membership table if you create a user and go to manage that user you see it has a Description labelled text box this maps through to the Comment field.
Maybe I'm using the wrong terms! sorry...
I don't quite understand what "comment field" you are talking about, because the default Web Site Administration Tool created users don't have such fields.
If you want to create such a field you would need to implement different MembershipProvider
class or work with Profile properties
I would recommend you to read these articles first:
- Examining ASP.NET's Membership, Roles, and Profile
- Storing Additional User Information
EDIT:
For that particular "Description" field (wich I'm sure wasn't there when I was looking for it >.<), it really puts data into "aspnet_Membership" table "Comment" column.
You can easily access it with MembershipUser
class:
@{MembershipUser user = Membership.GetUser();}
@if ( user != null)
{
@user.Comment
}
Razor syntax
EDIT
Membership.GetUser()
support simple overrides so you don't really need to use Context.User.Identity.Name
as parameter for currently logged-on user.
Gotta go with Ilya on this one... I'm not seeing a "comment" field in my instance of Web Site Adminstration.
But, a possible answer to your question would be ASP.NET Profiles: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
精彩评论