Pergunta

Estou tentando mostrar meus colegas no meu Webpart personalizado. Então, adicionando o ícone de presença a cada colega. Está aparecendo bem quando o colega é apenas 1. Se tivermos um colega mais de 1 ícone de presença mostrando para o 1º colega, você também poderá soltar esse ícone, mas outros colegas, é exibir um ícone mais simples da presença (Greyout) (não diminui o momento).

O código é assim.

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

Foi útil?

Solução

Seu IMG precisa ter um ID único definido. Parece que você estava quase lá, atribuindo o valor "IMID[GUID]"

Em vez disso, tente:

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>";
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top