Previously, after creating a discussion board, you need to access the details of the discussion in another site, so you can find the address of the discussion topic. The following is the method in use.
Through event listening (for the creation of listening events, refer to the MSDN example), after the discussion board is created, obtain its address. Currently there is manual splicing. If there is a better method, please note it;
Create a discussion board named text. The address is as follows:
Http: // win-l8muo3ci7hb/sites/Project/Lists/List4/Flat. aspx?
RootFolder = % 2 Fsites % 2 FProject % 2 FLists % 2FList4% 2 Ftest &
FolderCTID = 0x012002000011AC68D38FA24BAE274F76B33E6338
Where,
RootFolder parameter: After URL transcoding, the result of anti-transcoding is
RootFolder =/sites/Project/Lists/List4/test
It is to discuss the list address + topic.
FolderCTID parameter: After the trial is deleted, you can access the discussion board and cannot find its meaning, so it is not added.
/// <Summary>
/// An item was added.
/// </Summary>
Public override void ItemAdded (SPItemEventProperties properties)
{
Base. ItemAdded (properties );
If (properties. ListTitle = "Project Discussion ")
{
Try
{
Using (SPWeb web = properties. OpenWeb ())
{
String userName = web. CurrentUser. Name;
String projectName = web. Title;
String projectUrl = web. Url;
SPList list = web. Lists [properties. ListId];
String title = list. Fields. GetField ("topic"). InternalName;
String titleValue = properties. ListItem [title]. ToString ();
// Obtain the Topic link
// Properties. List. DefaultDisplayFormUrl is the default address of the displayed list. You can find the list address of the discussion board;
String tmpUrl = properties. List. DefaultDisplayFormUrl. Substring (0, properties. List. defadisplaydisplayformurl. LastIndexOf ('/'));
String RootFolder = tmpUrl + "/" + titleValue;
// Url transcoding to avoid address errors when Chinese characters are included
RootFolder = System. Web. HttpUtility. UrlEncode (RootFolder );
String discussionUrl = "http: //" + Environment. MachineName + tmpUrl + "/Flat. aspx? RootFolder = "+ RootFolder;
}
}
Catch (Exception ex)
{
}
}
}