1. Create Files like in directory above.
2. Elements.xml:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Simple List Actions"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1101"
Title="My Action"
Description="A Simple Action Menu"
ControlAssembly="CustomActions.SimpleAction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5483709352c77bd4"
ControlClass="CustomActions.SimpleAction.SimpleActionExample"/></Elements>
3. Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="886DFDD5-B323-4593-9471-717C863F4CB4"
Title="Custom Simple Action Example"
Scope="Web"
Hidden="FALSE"
>
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>
4. SimpleActionExample.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Diagnostics;
using System.Web.UI;
using Microsoft.SharePoint;
namespace CustomActions.SimpleAction
{
public class SimpleActionExample: System.Web.UI.WebControls.WebControl
{
protected override void OnLoad(EventArgs e)
{
EnsureChildControls();
base.OnLoad(e);
}
protected override void CreateChildControls()
{
SPWeb site = SPContext.Current.Web;
MenuItemTemplate _action = new MenuItemTemplate();
_action.Text = "My Action1";
_action.Description = "My Action1";
_action.ImageUrl = "/_layouts/images/NEWITEM.GIF";
_action.ClientOnClickNavigateUrl = "http://www.ttt.com";
Controls.Add(_action);
}
7. Deploy Descripture
cd "$(ProjectDir)"xcopy "$(TargetDir)*.dll" "C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin\" /ys"
%programfiles%\microsoft visual studio 8\sdk\v2.0\bin\gacutil" /i "$(TargetPath)" /nologo /f
xcopy "TEMPLATE" "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\" /ys
6. Deploy the feature.
stsadm -o deactivatefeature -name CustomSimpleAction -url http://site/ -force
stsadm -o uninstallfeature -name CustomSimpleAction -force
stsadm -o execadmsvcjobs
stsadm.exe -o installfeature -name CustomSimpleAction
stsadm.exe -o activatefeature -name CustomSimpleAction -url http://site/ -force
stsadm -o execadmsvcjobs
iisreset
Then you found the action is not comming out......
Why????
Answer is here. You have to put it on SafeControl.
<SafeControl Assembly="CustomActions.SimpleAction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5483709352c77bd4" Namespace="CustomActions.SimpleAction" TypeName="*" Safe="True" />
Use
<?xml version="1.0" encoding="utf-8" ?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="C467C5CE-5290-4A2B-A243-092F5A51E4E0" >
<FeatureManifests>
<FeatureManifest Location="CustomActions.SimpleAction\feature.xml" />
</FeatureManifests>
<Assemblies>
<Assembly DeploymentTarget="GlobalAssemblyCache" Location="CustomActionOCRPDFInList.dll">
<SafeControls>
<SafeControl
Assembly="CustomActions.SimpleAction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5483709352c77bd4"
Namespace="CustomActions.SimpleAction"
TypeName="*"
Safe="True" />
</SafeControls>
</Assembly>
</Assemblies>
</Solution>
Or directly put in Web.config file
沒有留言:
張貼留言