Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > How to check the Gender View modes: 
User avatar
Member
Member
v.tankaria-yahoo - 3/31/2011 5:04:37 AM
   
How to check the Gender
<%# IfEmpty(Eval("TeaserImage")," ",

"<div class='newsImage'>"+ GetImage("TeaserImage",140,114) +"</div>") %>

In the above code where the condition evaluates i have blank output . if it has a image it shows image

But
instead of blank i want to check if its gender is male or female and show respected default image for male or female

here we have IfEmpty to check its empty or not .. how to check what is evaluted

(Eval("Gender")=="Male")?"<img src='http://192.168.4.10/iisroot/KenticoLiveServer/images/mail.jpg'>","<img src='http://192.168.4.10/iisroot/KenticoLiveServer/images/femail.jpg'>"

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/31/2011 7:30:00 AM
   
RE:How to check the Gender
Hi,

you can return path to image using following code:


<script runat="server">

public static string getGenderImageUrl()
{
switch (CMSContext.CurrentUser.UserSettings.UserGender.ToString()){
case "1": return "manImageURL";
case "2": return "femaleImageURL";
default: return "no image URL";
}
}

</script>

<img src='<%= getGenderImageUrl() %>' alt="alt text" />


Best regards,
Ivana Tomanickova