2009年8月16日 星期日

Create Action in ActionMenu

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

2009年8月3日 星期一

Invalid postback or callback argument

EXCEPTION:

Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Just make sure EnableEventValidation is set to false on web.config, otherwise the following error is being thrown:

Hide Workflow Link on Item Context Menu for Document List

1. Open CORE.JS on C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
2. find the words: function AddDocLibMenuItems(m, ctx)
3. under the function, find words: AddWorkflowsMenuItem(m, ctx);
4. comment that out. or Add if (ctx.ListTitle != "Test Document") to focus on some list title.
5. Save it of course.