In my initial attempt to create a custom action for a SharePoint list, I specified it as follows:
< CustomAction
Id = "SoftArtisans.Tutorial.MenuItemExcel"
GroupId = "ActionsMenu"
Location = "Microsoft.SharePoint.StandardMenu"
RegistrationType = "List"
Sequence = "1000"
Title = "Export to SoftArtisans OfficeWriter for Excel"
ImageUrl = "/_layouts/images/softartisanstutorial/actionicon_excel.gif" >
< UrlAction Url = "/_layouts/SoftArtisansTutorial/ExcelWriter.aspx?ListId={ListId}" />
</ CustomAction >
|
WSS replaces the special {ListId} token with the actual id of the list. In the application page I tried to retrieve the list from which the action had originated as follows:
SPWeb web = SPContext.Current.Web; string listId = Request.QueryString[ "ListId" ];
SPList list = web.Lists[ new Guid(listId)];
|
However, I found that SPContext.Current.Web always returned the root-level Web site, even if the action was activated from a child site. So I modified the URL of the action to include the URL of the site: Continue reading Targeting a SharePoint Site in a Custom Action