Question

I have an own UI for discussion messages. The issue is the Url of the actual SPListItem doesn't help:

SPListItem message = //get message
var url = message.Url; //returns "/Lists/forum/hello/2.000"

What I want is the url "http://contoso/Lists/forum/Flat.aspx?RootFolder=/Lists/forum/hello&CTID=xxx"

This is what I get when I go to a discussion thread.

Was it helpful?

Solution

The CTID is the ContentTypeId from the listitem and the rootfolder is ServerUrl from the listitem.

Try this code to see if it gives you the url you want. You could also dynamically get the viewurl if you desire.

var url = "http://contoso/Lists/forum/Flat.aspx?RootFolder=" + message["FileDirRef"] + "&CTID=" + message["ContentTypeId"];
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top