左右间

行走在左右之间

博客园 首页 新随笔 联系 订阅 管理

[Guid("288802c4-4dfe-45b6-bb28-49dda89ec225")]
    public class MyWebPartVerb:WebPart
    {
        //通过重载这个属性可以添加自定义的Verbs.
        public override WebPartVerbCollection Verbs
        {
            get
            {
                //这是一个触发JavaScript事件的WebPart.
                WebPartVerb objFirst = new WebPartVerb("FirstVerbId","alert('XXXXXXX!');");
                objFirst.Text = "first verb text";
                objFirst.Description = "first verb description";
                objFirst.ImageUrl = "_layouts/images/loisandclark/favicon.gif";

                //这是一个触发Server端事件的WebPart.
                WebPartVerb objSecond = new WebPartVerb("SecondVerbId",new WebPartEventHandler(SecondVerbHandler));
                objSecond.Text = "second verb text";
                objSecond.Description = "second verb description";
                WebPartVerb[] objVerbs = new WebPartVerb[] {objFirst, objSecond};

                //在这里,我们保留原有的Verbs.
                WebPartVerbCollection objVerbCollection = new WebPartVerbCollection(base.Verbs, objVerbs);
                return objVerbCollection;
            }
        }

        protected void SecondVerbHandler(object sender, WebPartEventArgs args)
        {
            //Do something...
        }
    }

posted on 2008-04-14 16:30  左右间  阅读(603)  评论(0编辑  收藏  举报