Tutorial :Help adding a button to the “Actions” menu on a list



Question:

I have created a CustomAction feature to add a button to the "Actions" menu on a list. When I don't specify the ControlAssembly/ControlClass attributes then the button shows up. When I specify those attributes the button does not show up. I have tried adding a matching SafeControl element in the site web.config. I am using VSeWSS.

UPDATE - removed link to other question - not sure how i did that. My question is can anyone tell me why my CustomAction button is not showing up when I specify the ControlAssembly and ControlClass attributes ?

UPDATE 2 - RegenConfigTemp actually does inherit from WebControl, sorry! My machine with web access is different from my dev machine and there is no way to move files between them short of burning a CD.

here are my files:

  manifest.xml  <?xml version="1.0" encoding="utf-8"?>  <Solution SolutionId="GUIDHERE" xmlns="http://schemas.microsoft.com/sharepoint/">    <FeatureManifests>      <FeatureManifest Location="RegenConfigTemp\feature.xml" />    </FeatureManifests>    <Assemblies>      <Assembly Location="WebFeature.dll" DeploymentTarget="GlobalAssemblyCache" />    </Assemblies>  </Solution>  
  feature.xml  <Feature Id="GUIDHERE" Title="RegenConfigTemp" Scope="Web" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">    <ElementManifests>      <ElementManifest Location="RegenConfigTemp\Module.xml" />    </ElementManifests>  </Feature>  
  Module.xml  <?xml version="1.0" encoding="utf-8"?>  <Elements Id="GUIDHERE" xmlns="http://schemas.microsoft.com/sharepoint/">    <CustomAction      Id="GUIDHERE"      RegistrationType="List"      RegistrationId="1981"      GroupId="ActionsMenu"      Location="Microsoft.SharePoint.StandardMenu"      Sequence="1000"      Title="Regenerate List Contents"      ControlAssembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere"      ControlClass="WebFeature.RegenConfigTemp"    ></CustomAction>  </Elements>  
  RegenConfigTemp.cs  using System;  using System.Runtime.InteropServices;  using System.Web.UI.WebControls;  using Microsoft.SharePoint.WebControls;    namespace WebFeature  {      [Guid("GUID HERE MATCHES 1st GUID in Module.xml")]      public class RegenConfigTemp : WebControl      {          protected override void OnLoad(EventArgs e)          {              this.EnsureChildControls();              base.OnLoad(e);          }          protected override void CreateChildControls()          {              base.CreateChildControls();          }      }  }  

I added the following to the web.config

  <SafeControl Assembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere" Namespace="WebFeature" TypeName="RegenConfigTemp" Safe="True" />


Solution:1

Turns out the problem was in Module.xml. I was missing the 'equals' sign after 'Version' in this (corrected) line: ControlAssembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere"

I got on the right trail b/c I discovered Sharepoint's diagnostic logging, and the first comment on this blog: http://blog.lostparticles.net/?p=23 was my problem exactly.

Thanks for y'alls help.

UPDATE: I had to fix web.config line as well. I ended up putting the safecontrol line in the manifest instead of directly in the web.config; thanks JMD. (BTW, why doesn't VSeWSS do that for me, when it does for web parts?)


Solution:2

Are you sure that your code is supposed to render anything? Which class are you inheriting from and where is your render code? Have you checked the SharePoint log for any exception?

This is not an answer to your question, but you can place your SafeControl tag in the manifest instead of the web.config.


Solution:3

Surely RegenConfigTemp should be inheriting from something? At present you're not adding any controls, so if you're overriding an empty control that would be why you're not seeing anything. If nothing else, try setting a breakpoint or adding some diagnostic tracing to CreateChildControls() to see if the code is executing.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »