Sharepoint 仅为第一人称显示状态图标
我试图在我的自定义Web部件中显示我的同事。所以我给每个同事添加了状态图标。当同事只有1岁时,表现良好。如果我们有超过1名同事 显示第一位同事的状态图标您也可以删除该图标,但其他同事则显示简单的状态图标(灰显)(不可下拉) 代码是这样的Sharepoint 仅为第一人称显示状态图标,sharepoint,web-parts,user-presence,Sharepoint,Web Parts,User Presence,我试图在我的自定义Web部件中显示我的同事。所以我给每个同事添加了状态图标。当同事只有1岁时,表现良好。如果我们有超过1名同事 显示第一位同事的状态图标您也可以删除该图标,但其他同事则显示简单的状态图标(灰显)(不可下拉) 代码是这样的 private static Panel GetUserInfo(UserProfile profile,Panel html, int cnt) { LiteralControl imnrc = new LiteralControl()
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;
}
}
private静态面板GetUserInfo(UserProfile配置文件、面板html、int-cnt)
{
LiteralControl imnrc=新的LiteralControl();
imnrc.Text=“”;
html.Controls.Add(imnrc);html.Controls.Add(GetNameControl(profile));//html.Controls.Add(newliteralcontrol(“
”));
返回html;
}
私有静态控件GetNameControl(用户配置文件)
{
//bool hasMySite=profile[PropertyConstants.PublicSiteRedirect].Value==null?false:true;
bool hasMySite=string.IsNullOrEmpty(profile.PublicUrl.ToString())?false:true;
字符串名称=配置文件[PropertyConstants.PreferredName].Value.ToString();
如果(hasMySite)
{
超链接控件=新建超链接();
control.NavigateUrl=String.IsNullOrEmpty(profile.PublicUrl.ToString())?null:profile.PublicUrl.ToString();
控件。样式。添加(“文本装饰”,“无”);
control.Text=名称;
返回控制;
}
其他的
{
LiteralControl=新的LiteralControl();
control.Text=名称;
返回控制;
}
}
您的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>";
imnrc.Text=”“;