[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need to show user profile information of a class.

Posted on 2009-02-14
6
Medium Priority
?
402 Views
Last Modified: 2012-05-06
I have the following:
how can I show the user information:

using System;
using System.Web;
using System.IO;
using System.Xml.Serialization;
using System.Web.Caching;
 
public static class UserProfile
{
    public class Personal
    {
        public static System.String UserName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("UserName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("UserName", value); }
        }
 
        public static System.String Password
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Password") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Password", value); }
        }
 
        public static System.String Email
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Email") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Email", value); }
        }
 
        public static System.String FirstName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("FirstName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("FirstName", value); }
        }
 
        public static System.String LastName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("LastName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("LastName", value); }
        }
 
        public static System.DateTime DOB
        {
            get { return (System.DateTime)HttpContext.Current.Profile.GetPropertyValue("DOB"); }
            set { HttpContext.Current.Profile.SetPropertyValue("DOB", value); }
        }
 
        public static System.Int32? Age
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Age") as System.Int32?; }
            set { HttpContext.Current.Profile.SetPropertyValue("Age", value); }
        }
 
        public static System.String Gender
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Gender") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Gender", value); }
        }
 
        public static System.String Seeking
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Seeking") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Seeking", value); }
        }
 
        public static System.String ConfirmationGUID
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("ConfirmationGUID") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("ConfirmationGUID", value); }
        }
 
        public static System.String UserIP
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("UserIP") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("UserIP", value); }
        }
 
        public static System.String SessionID
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("SessionID") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("SessionID", value); }
        }
 
    }
    public class Address
    {
        public static System.String Country
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Country") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Country", value); }
        }
 
        public static System.String Region
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Region") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Region", value); }
        }
 
        public static System.String City
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("City") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("City", value); }
        }
 
        public static System.String ZipCode
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("ZipCode") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("ZipCode", value); }
        }
 
    }
    public class Preferences
    {
        public static String Theme
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Theme") as String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Theme", value); }
        }
 
        public static String Culture
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Culture") as String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Culture", value); }
        }
 
    }
    public static void Save()
    {
        HttpContext.Current.Profile.Save();
    }
}

Open in new window

0
Comment
Question by:mathieu_cupryk
  • 4
6 Comments
 
LVL 27

Expert Comment

by:nmarun
ID: 23641591
Your definition of a class is incorrect. You have defined a class inside a class. What is it that you are trying to do?
0
 

Author Comment

by:mathieu_cupryk
ID: 23641594
to create a userprofile class related to the web.config.
0
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 1500 total points
ID: 23641640
It looks like you are looking to create a custom profile provider.

To link it to your web.config file, you would need to do something like this, specifically setting the "defaultProvider" to point to your class name.

<profile defaultProvider="UserProfile">
  <properties>
     <add name="UserName" />
     <add name="Password" />
     etc, etc, etc,
  </properties>
</profile>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mathieu_cupryk
ID: 23642247
i created a customer provider for my web.config.
now I would liket to create a method to show user
0
 

Author Comment

by:mathieu_cupryk
ID: 23642499
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }

    public Personal

        (string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         Int32? age,
         string gender,
         string seeking,
         string confirmationguid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
    }    

    private string username = "";
    public string UserName
    {
         get { return username;}
         set { username = value;}
    }

    private string password = "";
    public string Password
    {
        get { return password;}
        set { password = value;}
   }

    private string email = "";
    public string Email
    {
        get { return email;}
        set { email = value;}
    }

    private string firstname = "";
    public string FirstName
    {
        get { return FirstName;}
        set { FirstName = value;}
    }

    private string lastname = "";
    public string LastName
    {
        get { return LastName;}
        set { LastName = value;}
    }

    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return DOB;}
        set { DOB = value;}
    }

    private Int32? age = 0;
    public Int32? Age
    {
        get { return Age;}
        set { Age = value;}
    }  

    private string gender = "";
    public string Gender
    {
        get { return Gender;}
        set { Gender = value;}  
    }

    private string seeking = "";
    public string Seeking
    {
        get { return Seeking;}
        set { Seeking = value;}
    }

    private string confirmationguid = "";
    public string ConfirmationGUID
    {
        get { return ConfirmationGUID;}
        set { ConfirmationGUID = value;}
 
    }


   
}
I need you to veify this
0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31546945
u are just providing a solution that i purposed in my question.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 10 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question