Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
MenuTemplate menuTemplate = new MenuTemplate();

menuItem = new MenuItemTemplate("Delete document", "/_layouts/images/delete.gif");
            menuItem.ClientOnClickScript = ""; // What should I put there
            menuTemplate.Controls.Add(menuItem);

On line, menuItem.ClientOnClickScript, what should I put there, so that I can delete document?

share|improve this question

1 Answer 1

You need to call a Javascript (or SharePoint JS-ECMA) function passing "this" as a parameter (plus any other parameters you see fit).

"ConfirmDeleteThenPostBack(this, '%SomeParameter%')";

The function must also exist already loaded, e.g. via a ScriptLink control in the master page, or any other technique available (e.g. script tags).

One example doing exactly that could be seen here http://johanleino.wordpress.com/2009/05/12/solving-using-the-clientonclickusingpostbackevent-in-ascx-usercontrols/ and a full example to build your custom menus on SPGridView is http://blogs.msdn.com/b/powlo/archive/2007/02/25/displaying-custom-data-through-sharepoint-lists-using-spgridview-and-spmenufield.aspx

share|improve this answer
    
Ok. I have seen the links. But I need a javascript function for this. Can u write a function for me? –  SPBeginer Apr 4 '13 at 11:16

Your Answer

 
discard

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.