承接MOSS各种工作流开发 联系人:王先生.电话:18618405729QQ:252385878 QQ群:41696750 MSN:wanghao-3@hotmail.com

导航

Feature Action List Settings


今天很无赖。。很痛苦。。。很郁闷。 。。。。


首先 code .cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace ActionDemo
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:ListSettingsMenu runat=server></{0}:ListSettingsMenu>")]
    public class ListSettingsMenu : WebControl
    {
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState["Text"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["Text"] = value;
            }
        }


        protected override void CreateChildControls()
        {
            //base.CreateChildControls();
            SubMenuTemplate listSettings = new SubMenuTemplate();
            listSettings.Text = "List Settings";
            listSettings.Description = "Manage settings for lists on this site";
            listSettings.ImageUrl = "/_layouts/images/lg_ICASCX.gif";

            foreach (SPList list in SPContext.Current.Web.Lists)
            {
                if (!list.Hidden)
                {
                    MenuItemTemplate listItem = new MenuItemTemplate();
                    listItem.Text = list.Title;
                    listItem.Description = string.Format(
                        "Manage settings for {0}", list.Title);

                    listItem.ImageUrl = list.ImageUrl;

                    string url = string.Format(
                        "{0}/_layouts/listedit.aspx?List={{{1}}}",
                        SPContext.Current.Web.Url, list.ID.ToString());
                    listItem.ClientOnClickNavigateUrl = url;

                    listSettings.Controls.Add(listItem);


                }
            }

            this.Controls.Add(listSettings);
        }
        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write(Text);
        }
    }
}


Feature
feature.xml

<Feature xmlns="http://schemas.microsoft.com/sharepoint/"

         Id="{abeaae41-f8bc-4d60-b793-1ab65e633009}"
         Title="AA is great "
         Description="default Site Actions menu of WSS site by adding extra menu options."
         Scope="Site"
        
         >
 <ElementManifests>
  <ElementManifest Location="manifest.xml"/>
 </ElementManifests>

</Feature>

manifest.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

 <CustomAction Id="{99777c4a-55d9-459b-aefe-e38b0d610ee1}"
      Location="Microsoft.SharePoint.StandardMenu"
      GroupId="SiteActions"
      ControlAssembly="ActionDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bf2af071df56a875"
      ControlClass="ActionDemo.ListSettingsMenu"
    >
 </CustomAction>

</Elements>


Dll放在 GAC 或者BIN

然后 二个xml 文件放在
Feature  下面,自己建立一个文件夹

在 站点的Web.Config 文件里面注册 这个dll
这个不用我写吧。。一般的WebPart 都需要。。

然后安装

 

@SET TEMPLATEDIR="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\"

@SET STSADM="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm"

xcopy /e /y TEMPLATE\* %TEMPLATEDIR%\Template

@ECHO ON

REM %STSADM% -o installfeature -name MyCustomListSettings -force
REM %STSADM% -o activatefeature -name MyCustomListSettings -force -url http://server:8000/

REM IISRESET /timeout:0


CustomAction 可以设置 Microsoft.SharePoint.StandardMenu

当然别的都可以设置。。。发挥你的想象去吧。/。。。


代码没有任何价值。。只是一种方式。。。


今天特烦。。。。








posted on 2008-05-09 16:29  A A  阅读(630)  评论(0编辑  收藏  举报