我试图在我的自定义网站部分中展示我的同事。所以我向每个同事添加了状态图标。当同事只有1时,它显示正常。如果我们有超过1的同事 Presence Icon显示为第一位同事你可以下载那个Icon,但其他同事则显示简单的Presense Icon(灰色)(不是下拉即将来临)。
代码是这样的。
private static Panel GetUserInfo(UserProfile profile,Panel html, int cnt)
{
LiteralControl imnrc = new LiteralControl();
imnrc.Text = "<span style=\"padding: 0 5px 0 5px;\"><img border=\"0\" valign=\"middle\" height=\"12\" width=\"12\" src=\"/_layouts/images/imnhdr.gif\" onload=\"IMNRC('" + profile[PropertyConstants.WorkEmail].Value.ToString() + "')\" ShowOfflinePawn=1 id=\"IMID[GUID]\" ></span>";
html.Controls.Add(imnrc); html.Controls.Add(GetNameControl(profile)); //html.Controls.Add(new LiteralControl("<br>"));
return html;
}
private static Control GetNameControl(UserProfile profile)
{
//bool hasMySite = profile[PropertyConstants.PublicSiteRedirect].Value == null ? false : true;
bool hasMySite =string.IsNullOrEmpty(profile.PublicUrl.ToString()) ? false : true;
string name = profile[PropertyConstants.PreferredName].Value.ToString();
if (hasMySite)
{
HyperLink control = new HyperLink();
control.NavigateUrl = String.IsNullOrEmpty(profile.PublicUrl.ToString()) ? null : profile.PublicUrl.ToString();
control.Style.Add("text-decoration","none");
control.Text = name;
return control;
}
else
{
LiteralControl control = new LiteralControl();
control.Text = name;
return control;
}
}
http://i700.photobucket.com/albums/ww5/vsrikanth/presence-1.jpg
答案 0 :(得分:3)
你的img需要设置一个唯一的ID。通过为其分配值“IMID[GUID]
”
而是尝试:
imnrc.Text = "<span style=\"padding: 0 5px 0 5px;\"><img border=\"0\" valign=\"middle\" height=\"12\" width=\"12\" src=\"/_layouts/images/imnhdr.gif\" onload=\"IMNRC('" + profile[PropertyConstants.WorkEmail].Value.ToString() + "')\" ShowOfflinePawn=1 id=\"IMID" + Guid.NewGuid().ToString() + "\" ></span>";