Customizing Custom Web Part Menu in SharePoint

Any standard web part within SharePoint would have menu options like Minimize, Close, and Modify Shared Web Part. We can even add our own custom menu options over there. They are referred to as verbs in web part’s context. We could add three types of web part menu verbs.

Client Side –We could specify JavaScript over here.

Server Side – We can attach event handler over here.

Both – We could have both JavaScript and event handler specified.

Let’s take a simple example where we would be adding all the above three kind of verbs.

Create a web part project within Visual Studio.

Put the following code for web part,

It would have a text box that would show the text set using the event handler specified in the server side verb.


    public class WebPartMenuVerbWebPart : System.Web.UI.WebControls.WebParts.WebPart


        public WebPartMenuVerbWebPart()




        protected  TextBox txtInfo;

        protected override void CreateChildControls()


            txtInfo = new TextBox();



        public override WebPartVerbCollection Verbs




                // Client side verb

                WebPartVerb clientSideVerb = new WebPartVerb(“clientID”, “javascript:alert(‘Hello World from Java Script Verb!’);”);

                clientSideVerb.Text = “Client Side Verb”;

                // Server side verb

                WebPartVerb serverSideVerb = new WebPartVerb(“serverID”, new WebPartEventHandler(ServerVerbEventHandler));

                serverSideVerb.Text = “Server Side Verb”;

                // Verb for both client side and server side

                WebPartVerb bothSideVerb = new WebPartVerb(“bothID”, new WebPartEventHandler(ServerVerbEventHandler), “javascript:alert(‘Hello World from Java Script Verb!’);”);

                bothSideVerb.Text = “Both Side Verb”;          

                WebPartVerbCollection wbVerbCollection = new WebPartVerbCollection(base.Verbs, new WebPartVerb[] { clientSideVerb, serverSideVerb, bothSideVerb  });

                return wbVerbCollection;



        protected void ServerVerbEventHandler(object sender, WebPartEventArgs args)


            txtInfo.Text=“Hello world from Server Side Verb”;                           




That’s it …

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

4 thoughts on “Customizing Custom Web Part Menu in SharePoint”

Share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.