我创建了一个CustomAction功能,可以在列表的“操作”菜单中添加一个按钮。当我没有指定ControlAssembly / ControlClass属性时,按钮会显示。当我指定这些属性时,按钮不会显示。我尝试在站点web.config中添加匹配的SafeControl元素。我正在使用VSeWSS。
更新 - 删除了其他问题的链接 - 不知道我是怎么做到的。 我的问题是,当我指定ControlAssembly和ControlClass属性时,有人能告诉我为什么我的CustomAction按钮没有出现吗?
更新2 - RegenConfigTemp实际上继承自WebControl,对不起!我的具有Web访问权限的计算机与我的dev计算机不同,除了刻录CD之外无法在它们之间移动文件。
这是我的文件:
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(); } } }
我将以下内容添加到了web.config
<SafeControl Assembly="WebFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=myPKTokenHere" Namespace="WebFeature" TypeName="RegenConfigTemp" Safe="True" />
答案 0 :(得分:1)
原来问题出在Module.xml中。在此(更正)的行中,我在'Version'之后错过了'equals'符号: ControlAssembly =“WebFeature,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = myPKTokenHere”
我找到了正确的路径b / c我发现了Sharepoint的诊断日志记录,以及此博客的第一条评论:http://blog.lostparticles.net/?p=23确切地说是我的问题。
感谢您的帮助。
更新:我还必须修复web.config行。我最终将safecontrol行放在清单中而不是直接放在web.config中;谢谢JMD。 (顺便说一句,为什么VSeWSS不为我做这个,当它用于网页部件?)
答案 1 :(得分:0)
您确定您的代码应该呈现任何内容吗?您继承了哪个类以及渲染代码在哪里?您是否检查过SharePoint日志中的任何异常?
这不是您问题的答案,但您可以将SafeControl标记放在清单中而不是web.config中。
答案 2 :(得分:0)
当然RegenConfigTemp
应该继承某些东西?目前你没有添加任何控件,所以如果你要覆盖一个空控件,这就是为什么你没有看到任何东西。如果没有别的,请尝试设置断点或向CreateChildControls()
添加一些诊断跟踪,以查看代码是否正在执行。