SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I add my method instead of URL of a website, I can see another option as "ClientOnClickScript" but not sure how exactly I can do it tho, here's my code

public class MyUserControl: WebControl
    private MenuItemTemplate _action;

    protected override void CreateChildControls()
       _action = new MenuItemTemplate
         Text = "hahahahaha",
         Description = "whatever",
         ImageUrl = "/_layouts/images/abc.gif",
         ClientOnClickNavigateUrl = ""


    private void myMethod(string linkToURL, string documentLibraryName)

I got these 4 options I think but not sure which one will work,

  • ClientOnClickNavigateUrl
  • ClientOnClickPostBackConfirmation
  • ClientOnClickScript
  • ClientOnClickUsingPostBackEvent
share|improve this question
up vote 2 down vote accepted

To handle click event of MenuItemTemplate.
1. Subclass MenuItemTemplate, IPostBackEventHandler and declare an event inside the class to which you can subscribe.
2. Instantiate this class instead of MenuItemTemplate and handle the event. That's it.

Browse this excellent article Handling a PostBack for more details. Good Luck!.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.