Extended User Data CS 3.0

  •  I have been trying to implement extended user data in cs 3.0  and i am running into some trouble displaying that info on a users profile. I have looked over several posts http://www.tankete.com/core/blogs/jose_lema/archive/2006/06/29/CS-Spotlight_3A00_-Extended-User-Data.aspx  but it seems that that detailed a cs 2.1 instance.

    I have done the following

    Added the following code in communityserver.config

      <ExtendedUserData>
        <add name = "Quote" />

      </ExtendedUserData>

    Added this to languages/en-US/resources.xml 

    <resource name ="EditProfile_Quote">Quote</resource>

    Placed the following code in themes/default/user.edituser.aspx 

                                    <tr>
                                        <td class="CommonFormFieldName">
                                            <CSControl:ResourceControl runat="server" ResourceName="EditProfile_Quote" />
                                        </td>
                                        <td class="CommonFormField">
                                            <asp:Textbox id="Quote" Columns="30" MaxLength="50" runat="server" />
                                        </td>
                                    </tr>

    Thats about as far as i have got...the text box shows up and says "quote" like it should however if i write something and then save it the value is no longer displayed in the textbox i am guessing its not being saved to the database...as for displaying that info on a users public profile i am having some trouble there..i tried using the code from jose's blog however that does not work...if anyone has any ideas on how to make this work in CS 2007 that would be great  

    peace shakes

    Carolina Pulse

  • Hi shakes, 

    I just tried it myself and it worked fine on a local install of Community Server 2007. Here's two common mistakes:

    • Make sure your control name matches the case of the name in <ExtendedUserData>
    • Make sure you "touch" the web.config to force an app restart so <ExtendedUserData> is processed.

    Let me know if either of those was the problem...

    One is glad to be of service...

  • Jose, I have read pretty much everything I can find on extended data but I cannot seem to find any help with displaying a databind from a true or false field returned from a GetUserToView(). script I found in a post you made and since this is the first post I could find in CS2007 I thought this would be the most appropriate place. 

    I apologize for such a simple question but I am a newbie with quite a bit to learn...

    My intention would be to display the data in a Checkbox. I have tried using the databind inside of the checkbox but it blew-up on me.

    ex: <asp:Checkbox enabled="false" checked="like"<%=GetUserToView().GetExtendedAttribute("train")%> />

    Thanks

    Xing101

  • Jose,

    I have been able to get the extended user data to save properly and have displayed it on my profile using  <%= CSContext.Current.User.GetExtendedAttribute("Quote") %> however when i try to use the code below to allow other users to view this data i get a compilation error? I know this code was for 2.1 and I am running 2007 sp1 which is probably my problem.

     

    <script language="cs" runat="server">
    User GetUserToView()
    {
        User user = null;
        CSContext csContext = CSContext.Current;
        int userID = csContext.UserID;

        if (userID <= 0)
        {
            string username = Context.Request.QueryString["UserName"];
            if (username == string.Empty)
                throw new CSException(CSExceptionType.UserNotFound);
            else
                user = Users.GetUser(0, username, false, true);
        }
        else
        {
            user = Users.GetUser(csContext.UserID, false, true);
        }

        return user;
    }
    </script>

    Server Error in '/' Application.

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0103: The name 'Users' does not exist in the current context

    Source Error:


    Line 26:             throw new CSException(CSExceptionType.UserNotFound);
    Line 27: else
    Line 28: user = Users.GetUser(0, username, false, true);
    Line 29: }
    Line 30: else

    Source File: c:\websites\unseaw360\unseaw.com\Themes\default\User\userprofile.aspx    Line: 28


    function OnToggleTOCLevel1(level2ID) { var elemLevel2 = document.getElementById(level2ID); if (elemLevel2.style.display == 'none') { elemLevel2.style.display = ''; } else { elemLevel2.style.display = 'none'; } }


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

    peace shakes

    Carolina Pulse

  • Hi shakes,

    The code should continue to work in CS 2007. It appears that you're getting the following error: 

    shakes
    Compiler Error Message: CS0103: The name 'Users' does not exist in the current context

    because you need to let ASP.NET know where "Users" exists. Simply add:

    <%@ Import Namespace="CommunityServer" %>

    to your page and things should work just fine.

    Alternatively, if you're looking for an easy Chameleon way to access the data, you can skip all that inline code and just add the following control to your page:

    <CSControl:UserData runat="server" ExtendedAttribute="[your field here]" />

    One is glad to be of service...

  • Hi Jose, I was wondering, before I get started with making any code changes. Can Extended User Data be accesses and modified by CS Modules?

  • Hi cstewart,

    ExtendedUserData is simply a no-code feature to auto-save a user's extended attributes at registration and profile modification time. Since that data is indeed saved into ExtendedAttributes, you have access to it as you would any other extended attribute data during events handled by CSModules.

    One is glad to be of service...

  • Jose,

    Thank you so very much the chameleon way was exactly what i was looking for. 

    peace shakes

    Carolina Pulse

  • Thanks ... Very very gooooood ..

     

  • When I use this in the editprofile.aspx file, it works, but... I don't get the label beside the field.

     

    I've tried putting in the resource label, but no luck. Any ideas?

     

    My code:

                                           <tr>
                                    <td class="CommonFormFieldName">
                                         <CSControl:UserData runat="server" ExtendedAttribute="Company"
                                         ResourceName="EditProfile_AboutCompany" />
                                    </td>
                                    <td class="CommonFormField">
                                        <asp:TextBox id="Company" Columns="30" runat="server" MaxLength="50" />
                                    </td>
                                </tr>

  • Daniel, take a look at the 1st post in this thread, you need to use the ResourceControl to display the label.
  •  So would the CSControl:UserData and CSControl:ResourceControl go within the same < > tags? Could you give me an example?

  •  <tr>
                                        <td class="CommonFormFieldName">
                                            <CSControl:ResourceControl runat="server" ResourceName="EditProfile_AboutCompany" />
                                        </td>
                                        <td class="CommonFormField">
                                            <asp:Textbox id="Company" MaxLength="50" runat="server" />
                                        </td>
                                    </tr>

  • Of course, seperate <td> tags. Thanks for that!