Question

I have following lines of code for menuitemtemplate:

 MenuTemplate menuTemplate = new MenuTemplate(); 
menuItem = new MenuItemTemplate("Version History","/_layouts/images/versions.gif");
            menuItem.ClientOnClickScript = "" // what I put there
    menuTemplate.Controls.Add(menuItem);

ClientOnClickScript, what should I put there ? so that I can see versionHistory of the document?

Was it helpful?

Solution

The page showing versions is accessible as

<siteCollectionURL>/_layouts/versions.aspx?list=<ListID>&ID=<ItemId>&FileName=<ServerRelativeFileUrl>

So you need to know ListID, ItemID and ServerRelativeFileUrl as parameters. ) To launch it via the Javascript you would need something along these lines

LaunchVersionsDialog(this, '%ListId%', '%ItemId%', '%ServerRelativeFileUrl%')";

function LaunchVersionsDialog(elm, siteUrl, listId, itemId, serverRelativeFileUrl)
{

var versionsPageUrl = siteCollectionURL + '/_layouts/versions.aspx?list=' + listID + '&ID=' + itemId + '&FileName=' + serverRelativeFileUrl;

var options = SP.UI.$create_DialogOptions();
options.width = 600;
options.height = 400;
options.url = versionsPageUrl;

SP.UI.ModalDialog.showModalDialog(options);
}

One more thing missing is passing those parameters to by Setting Attributes from the Server Side Code when you call the function - for that i suggest you read some more here http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.menuitemtemplate.clientonclickscript.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top