Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Showing user pic in message board View modes: 
User avatar
Member
Member
dantahoua-gmail - 2/6/2012 3:32:11 PM
   
Showing user pic in message board
I would like to know if it's possible to show the picture of a registerred user in the Message Board like in the BlogCommentViewer...
Everybody can post on the message board but when the moderator or a registered user post a message, I would like to have is Avatar/Pic to show...
Any idea?
Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/7/2012 3:09:09 AM
   
RE:Showing user pic in message board
Hello,

You can use the same control, which is used in the Blog Comment Viewer web part. What is need to do is to place this control into the transformation, which is selected for your Message Board web part. So please just register this control in your transformation:

<%@ Register Src="~/CMSAdminControls/UI/UserPicture.ascx" TagName="UserPicture" TagPrefix="cms" %>


And add the following code to a place, where you want to display user's avatar:

<cms:UserPicture ID="userPict" runat="server" EnableViewState="false" Visible="true" OuterDivCSSClass="CommentUserPicture" RenderOuterDiv="true" Width="80" Height="80" UserID='<%#Eval("MessageUserID")%>' />


Best regards,
Jan Hermann

User avatar
Member
Member
dantahoua-gmail - 2/7/2012 7:47:37 AM
   
RE:Showing user pic in message board
Thanks! I'll try it right now!

User avatar
Member
Member
dantahoua-gmail - 2/17/2012 5:14:24 PM
   
RE:Showing user pic in message board
kentico_janh wrote: Hello,

You can use the same control, which is used in the Blog Comment Viewer web part. What is need to do is to place this control into the transformation, which is selected for your Message Board web part. So please just register this control in your transformation:

<%@ Register Src="~/CMSAdminControls/UI/UserPicture.ascx" TagName="UserPicture" TagPrefix="cms" %>


And add the following code to a place, where you want to display user's avatar:

<cms:UserPicture ID="userPict" runat="server" EnableViewState="false" Visible="true" OuterDivCSSClass="CommentUserPicture" RenderOuterDiv="true" Width="80" Height="80" UserID='<%#Eval("MessageUserID")%>' />


Best regards,
Jan Hermann


It works until a non registered user post a message...
As I understand if a non registered post a message, Kentico throw an error (probably because he cannot find an image or a userid) when trying to show the message...
The message is posted but cannot be displayed.
Is there a way to avoid that? Because I need to show a difference between registered user and not registered ones...
The error is:
<span title="Message: [CMSAbstractTransformation.DataBind]: Specified cast is not valid. 
Stack Trace:
at ASP.cmstransformations_bc9177ce_509f_489f_9a6d_2d3904da2ec1_community_transformations_messageboard_ascx.__DataBindinguserPict(Object sender, EventArgs e) in http://server/CMSTransformations/bc9177ce-509f-489f-9a6d-2d3904da2ec1/community/transformations/messageboard.ascx:line 11
at System.Web.UI.Control.OnDataBinding(EventArgs e)
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at CMS.Controls.CMSAbstractTransformation.DataBind()
" class="TransformationError">[CMSAbstractTransformation.DataBind]: Specified cast is not valid.</span>

If I remove the code to show the picture, everything is ok...
Thanks

User avatar
Member
Member
dantahoua-gmail - 2/17/2012 5:25:36 PM
   
RE:Showing user pic in message board
Is there a default user id I can use? So I can do a "IfEmpty", seems to work? Or I can create a specific user for that, but how can I have the id of a user? Please help me ;) !
Thanks! :)

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/18/2012 11:42:53 AM
   
RE:Showing user pic in message board
Hello,

Sure, default ID is 65 (public user).

Best regards,
Jan Hermann

User avatar
Member
Member
dantahoua-gmail - 2/20/2012 7:25:50 AM
   
RE:Showing user pic in message board
Thanks