Pregunta

I have a web application which stores customer details like username, firstname and email address ... etc...etc..

I am using Asp.Net Membership, also my web page where i will allow customers to register I'm using CreateUserWizard.

I would like to know how to save customer mobile numbers using asp.net Membership. In my sql table I have all the asp.net membership tables. However wanted to know how to customize the table to allow mobile numbers to be saved into database.

Any ideas?


I Have Custom UserProfile Class where I have setup the mobile property and other properties. How Can I save all the details into separate columns in database??

public class UserProfile : ProfileBase { public static UserProfile GetUserProfile(string username) { return Create(username) as UserProfile; }

    public static UserProfile GetUserProfile()
    {
        return Create(Membership.GetUser().UserName) as UserProfile;
    }


    [SettingsAllowAnonymous(false)]
    public string MobileNumber
    {
        get { return base["MobileNumber"].ToString(); }
        set { base["MobileNumber"] = value; }
    }

    //Few other properties.....



}

Here is my webconfig settings

  <providers>
    <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="EXAMPLE" applicationName="EXAMPLE" description="SqlProfileProvider for SampleApplication"/>
  </providers>
</profile>
¿Fue útil?

Solución

Use Profile properties. In web.config add <profile> entry.

<profile>
  <properties>
    <add name="MobileNumber"  />
  </properties>
</profile>

Otros consejos

Yes, just add the Profile property mentioned above and you can access this property by

Profile.MobileNumber = "12232";// to Save the Mobile No of current logged in user

ProfileProvider will automatically saves this for you in database.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top