More in this section

Forums / General Discussions / How to use UserProfileView control?

How to use UserProfileView control?

4 posts, 0 answered
  1. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    19 Apr 2011
    Link to this post
    Hi there,

    I'd like to change the default layout of UserProfileView and use it inside of my custom control. I tried to do this as I did it in Sitefinity 3.7:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="User.aspx.vb" Inherits="User" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Security.Web.UI" TagPrefix="prof" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <prof:UserProfileView ID="userProfile" runat="server">
                    <ControlDefinition>
                    <Views>
                        <asp:Literal runat="server" ID="FirstName"></asp:Literal>
                    </Views>
                    </ControlDefinition>
                </prof:UserProfileView>
            </div>
     
            <asp:ScriptManager runat="server" ID="ScriptManager1">
            </asp:ScriptManager>
        </form>
    </body>
    </html>

    Unfortunately, I have got the following error:
    Parser Error Message: Telerik.Sitefinity.Web.UI.ContentUI.ViewDefinitionCollection must have items of type 'Telerik.Sitefinity.Web.UI.ContentUI.Contracts.IContentViewDefinition'. 'asp:Literal' is of type 'System.Web.UI.WebControls.Literal'.

    Could you please provide an example how to modify the default layout of this control and use custom fields?

    Thank in advance,
    Anton.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Apr 2011
    Link to this post
    Hi Anton,

    To change the MasterListView template you should have the following declaration in your template.

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <telerik:RadListView ID="UserProfilesList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
        <LayoutTemplate>
            <ul class="sfusersListNameAvatar">
                <asp:PlaceHolder ID="ItemsContainer" runat="server" />
            </ul>
        </LayoutTemplate>
        <ItemTemplate>
            <li class="sfusersListItem">
                <sf:ImageField ID="predefinedImageField" runat="server" DataFieldType="Telerik.Sitefinity.Model.ContentLinks.ContentLink"
                    DisplayMode="Read" ShowDeleteImageButton="false" CssClass="sfusersListAvatar" DefaultSrc="~/SFRes/images/Telerik.Sitefinity.Resources/Images.DefaultPhoto.png" DataFieldName="Avatar" />
                 
                <sf:DetailsViewHyperLink ID="DetailsViewHyperLink1" runat="server" TextDataField="FirstName, LastName" TextDataFormat="{0} {1}" CssClass="sfusersListLnk" />
     
                <sf:FieldListView ID="DetailsViewText1" runat="server" Text="{0}" Properties="FirstName" WrapperTagName="" WrapperTagCssClass="" Visible="false" />
                <sf:FieldListView ID="DetailsViewText2" runat="server" Text="{0}" Properties="LastName" WrapperTagName="" WrapperTagCssClass="" Visible="false" />
            </li>
        </ItemTemplate>
    </telerik:RadListView>
    <sf:Pager id="pager" runat="server"></sf:Pager>

    You should set the public DefaultLayoutTemplatePath property to your customized template.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

  3. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    19 Apr 2011
    Link to this post
    Hi Ivan,

    Thanks for provided code snippet!

    I'm sorry, maybe I asked my question incorrectly, but actually I'm looking for a way to do the following thing.
    In Sitefinity 3.7 was a control Telerik.Security.WebControls.ManageProfile that allows displaying custom fields from a user account. There was a very simple way to map the different custom fields. I should only add the needed fields as Literal control something like this:

    <prof:ManageProfile ID="userProfile" runat="server" userName="admin">
        <ViewTemplate>
                <asp:Literal ID="CustomField1" runat="server"></asp:Literal>               
                <asp:Literal ID="CustomField2" runat="server"></asp:Literal>
                     ....   
        </ViewTemplate>
    </prof:ManageProfile>

    Is there a way to do the same in Sitefinity 4.1?

    Thanks,
    Anton
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Apr 2011
    Link to this post
    Hi Anton,

    Currently there is a bug that prevents the fields for editing (http://www.telerik.com/support/pits.aspx#/public/sitefinity/5634), but you can show them using Profile control introduced in Sitefinity 4.1 (Q1) release.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

4 posts, 0 answered