Monday, January 20, 2014

How to set UserName property value in customized MembershipUser class?

Because in base class UserName property is read only.
public virtual string UserName { get; }

So need to call base constructor to set the value
public class CustomerUser : MembershipUser
    {
        public string CID { get; set; }

        public CustomerUser(string username, string cid:
            base("CustomerMembershipProvider",
                                       username,
                                        null,
                                       null,
                                       null,
                                       null,
                                       true,
                                       false,
                                       System.DateTime.Now,
                                       System.DateTime.Now,
                                       System.DateTime.Now,
                                       System.DateTime.Now,
                                       System.DateTime.Now)
        {
            CID= cid;
        }
    }

Understanding Scope and Context in JavaScript

http://ryanmorr.com/understanding-scope-and-context-in-javascript/