How to use UserProfileView control?
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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
>
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
>
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
>
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