0

I am attempting to create a Visual Web Part to display users with presence (will be adding custom property to allow end users to choose which department's users they display)

However while I can retrieve and display data from the User Information List, it doesn't render as I might expect it to. Rather than showing the title (User's name/presence and hyperlink) in a list format, it is just showing them as strings.

cs

SPWeb currentWeb = SPContext.Current.Web;
SPListItemCollection listOfUsers = currentWeb.SiteUserInfoList.GetItems();
ListView1.DataSource = listOfUsers.GetDataTable();
ListView1.DataBind();

ascx

<asp:ListView ID="ListView1" runat="server">
 <ItemTemplate>
                <asp:Label ID="Title" runat="server" Text='<%# Eval("Title") %>' />
    </ItemTemplate>
</asp:ListView>

Is it possible to get my ascx to show the user with presence? rather than as just a string?

1 Answer 1

1

Generate some html dynamically like this:

<span>     
<img class="PresenceImage" src="/_layouts/images/imnhdr.gif" onload="IMNRC('USEREMAIL')" name="imnmark" ShowOfflinePawn="1" id="IMID[GUID]" />     
</span>

Javascript function "IMNRC" do the magic

Greetings

1
  • Thank you, Marco. This helped me down the right path. I managed to get it working using some more spans, classes and the sip attribute.
    – greensmith
    Sep 8, 2015 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.