1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Profile information

Profile information

8 posts, 0 answered
  1. Kalpana
    Kalpana avatar
    27 posts
    Registered:
    18 Dec 2008
    13 Feb 2009
    Link to this post
    Hi

    I have a login control. After the user logs in I want to display Welcome firstname. How do I get the firstname information in my code. The Profile.firstname doesnot return that information.

    Thanks

    Kalpana
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Feb 2009
    Link to this post
    Hello Kalpana,

    Thank you for using our services.

    Here is an sample that will return the currently logged user. You need to edit Admin.master and the code behind of the master page.

    Create a new label control

    <li id="userName1" class="userName" runat="server"><asp:Label id="userLabel1" runat="server" Text="Hello"></asp:Label></li

    Then in the code behinde put the following line on Page_Load

    this.userName1.Controls.Add(new LiteralControl(Telerik.Security.UserManager.GetCurrentUserName())); 

    I hope this helps.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Kalpana
    Kalpana avatar
    27 posts
    Registered:
    18 Dec 2008
    16 Feb 2009
    Link to this post
    Hi Ivan

    The GetUserName() returns the login name. I was trying to retrieve the first name and last name from the profile - when I create a user in the dashboard I give the first name and last name of the user - I want to retrieve that in my code.

    Thanks.

    Kalpana
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    16 Feb 2009
    Link to this post
    Hello Kalpana,

    The example below will return the logged user FirstName

    ProfileCommon profile = Profile.GetProfile(Membership.GetUser().UserName); 
           if (string.IsNullOrEmpty(profile.FirstName)) 
              Response.Write("The user FirstName is empty"); 
           else 
            { 
                 userLabel1.Text = profile.FirstName; 
            } 


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Kalpana
    Kalpana avatar
    27 posts
    Registered:
    18 Dec 2008
    16 Feb 2009
    Link to this post
    Thank you. That worked.

    Kalpana

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    16 Feb 2009
    Link to this post
    Hi Kalpana,

    I am glad to hear that everything works fine now.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Martin
    Martin avatar
    2 posts
    Registered:
    12 May 2009
    09 Nov 2009
    Link to this post
    Hello,

    I've added fields to the profile manager by adding them directly onto the web.config as:
                    <add name="EmailUpdates" type="bool"/>
                    <add name="EmailConfirmationKey" />
                    <add name="Address"/>
                    <add name="City"/>
                    <add name="State"/>
                    <add name="HomePhone"/>
                    <add name="CellPhone"/>
                    <add name="Gender"/>
                    <add name="DOB" type="datetime"/>

    and added them to the code behind as:
                    ProfileBase profile = ProfileBase.Create(username);
                    profile.SetPropertyValue("EmailUpdates", EmailUpdates.Checked);
                    profile.SetPropertyValue("EmailConfirmationKey", registrationKey);
                    profile.SetPropertyValue("Address", Address.Text);
                    profile.SetPropertyValue("City", City.Text);
                    profile.SetPropertyValue("State", State.SelectedValue);
                    profile.SetPropertyValue("Zipcode", Zipcode.Text);
                    profile.SetPropertyValue("HomePhone", HomePhone.Text);
                    profile.SetPropertyValue("CellPhone", CellPhone.Text);
                    profile.SetPropertyValue("Gender", Gender.SelectedValue);
                    profile.SetPropertyValue("DOB", new DateTime(Convert.ToInt32(Year.SelectedValue), Convert.ToInt32(Month.Text), Convert.ToInt32(Day.SelectedValue)));
                    profile.Save();

    I later access the control values to be used in javascript as:

    emm_dyn.initFields({"email":"<%=Email.ClientID%>",
    "title":" ",
    "gender":"<%=Gender.ClientID%>",
    "day": "<%=Day.ClientID%>",
    "month": "<%=Month.ClientID%>",
    "year": "<%=Year.ClientID%>",
    "address1": "<%=Address.ClientID%>",
    "city": "<%=City.ClientID%>",
    "state": "<%=State.ClientID%>",
    "zip": "<%=Zipcode.ClientID%>",
    "hphone": "<%=HomePhone.ClientID%>"
    });

    Each of these fields are replaced at run time with something like:
    ctl00_cphArticlesList_ctl00_Month
    ctl00_cphArticlesList_ctl00_Address
    etc...

    I can access all the fields and pass the values to the next step using javascript with the exception of First Name and Last Name which are already part of the profile. I've tried several methods but none of the work. What I need to access is: "ctl00_cphArticlesList_ctl00_manageProfile_ctl100_FirstName"

    How do I access First name, Last name to be used on my javascript function?

    Martin
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Nov 2009
    Link to this post
    Hi Martin,

    Can you try something like this:
    var firstnamecontrol = document.getElementById("FirstName");
    //use .value to get value of textbox
    firstnamecontrol.value

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered