Home > MOSS 2007, Uncategorized > Meeting Workspace: How to programatically add tabs

Meeting Workspace: How to programatically add tabs


When you add a page via the UI it adds it as a WebPartPage to a hidden list called “Workspace Pages”. It also does something internally to create the Tab because simply progammatically adding the WebPartPage to the hidden list doesnt seem to work.

After spending a lot of time investigating this issue I finally found a solution. The solution is listed below:
 

string newPage = string.Empty;
Type cmType = typeof(SPMeeting);
SPMeeting mtg = (SPMeeting)
Activator.CreateInstance(cmType,
BindingFlags.NonPublic | BindingFlags.Instance,
null, null, System.Globalization.CultureInfo.CurrentCulture,
null);
Type t = mtg.GetType();
t.InvokeMember(
"m_Web", BindingFlags.NonPublic
|
BindingFlags.Instance | BindingFlags.SetField,
null, mtg, new Object[] { web });
mtg.AddPage(
"JunkYard", 1, out newPage);

The SPMeeting class has a method “AddPage”. This class has no public constructors therefore you cannot instantiate it the normal way. Once you instantiate it you need to set, via reflection, m_Web which is a private member and holds the SPWeb object. The final step is to call the AddPage method passing it the name of the page you want to add, an instanceid (not sure what this is), and an out string parameter.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: