This worked for us. Not sure if it will work for you, have a look and see what you think:
Issue: Unable to trigger a trappable event with arguments from behind an ASP.Net 2.0 Menu control. Works fine on the top level menu items, but not on sub-items.
Basically, we have a list of commands arranged in a menu structure. Each time a command is sent, a javascript confirm box needs to be displayed that subsequently either processes a click event on a button or not. I think that the begining and end scenarios tie up with what your looking for. It's VB.Net, but should be extensible to a language of your choice.
Step one: Menu items
To each item we added the following:
Dim oMenuItem as New MenuItem
oMenuItem.Text = "Whatever"
oMenuItem.NavigateUrl = "javascript:validate('" & OutGoingCommand & "');"
Step two: JavaScript Function on Page:
function validate(zMessage)
{
// show confirm dialogue
if (confirm('Are you sure...?'))
{
document.getElementById('cmdCommandButton').click();
}
}
Step 3: Code behind
Write whatever code you need in the _Click event of cmdCommandButton.
Worked for us...
Cheers,
DS-9 Development Team.