OK, got it.
There is a lot of problems to solve, main thing is to reach the menu item in the actions menu, because there is no client ID for that. Therefore, the item hgas to be reached by the href property of the link - which is a bit complicated. Finally I found out that the href is
__doPostBack('dnn$ctr421$ModuleActions$actionButton', '6')
421 is the ModuleId, that was not hard to find. I suspected that '6' is the ID of the ModuleAction, but when investigating, I found out that this ID changed with every refresch - and even with every "? ModuleActions.GetActionByCommandName("DeleteStuff").ID" in the Direct Window at the same breakpoint:
? ModuleActions.GetActionByCommandName("DeleteStuff").ID
29
? ModuleActions.GetActionByCommandName("DeleteStuff").ID
33
? ModuleActions.GetActionByCommandName("DeleteStuff").ID
37
????
Finally I found out that '6' is the ActionID when creating the item - and that is NOT a (public) property of the ModuleAction. Again ???. Therefore I added a property "DeleteStuffActionID" and changed my code to in the ModuleActions property to:
DeleteStuffActionID = GetNextActionID();
actions.Add(DeleteStuffActionID, Localization.GetString("DeleteStuff.Action",
LocalResourceFile), "DeleteStuff", "Delete", IconController.IconURL("Delete"),
string.Empty, true, SecurityAccessLevel.Edit, true, false);
In the PreRender Event I added some JavaScript injection to hook on this link:
StringBuilder confirmDeleteScriptBuilder = new StringBuilder();
confirmDeleteScriptBuilder.Append("$(document).ready(function() {\r\n");
confirmDeleteScriptBuilder.Append(string.Format(" var deleteLink = $(\"a[href=' __doPostBack(\\\\\\\'dnn$ctr{0}$ModuleActions$actionButton\\\\\\\', \\\\\\\'{1}\\\\\\\')']\");\r\n", ModuleId, DeleteStuffActionID));
confirmDeleteScriptBuilder.Append(" deleteLink.dnnConfirm({\r\n");
confirmDeleteScriptBuilder.Append(string.Format(" text: \"{0}\",\r\n", Localization.GetString("ConfirmStuffDelete.Text", LocalResourceFile)));
confirmDeleteScriptBuilder.Append(string.Format(" yesText: \"{0}\",\r\n", Localization.GetString("Yes.Text")));
confirmDeleteScriptBuilder.Append(string.Format(" noText: \"{0}\",\r\n", Localization.GetString("No.Text")));
confirmDeleteScriptBuilder.Append(string.Format(" title: \"{0}\"\r\n", Localization.GetString("DeleteStuff.Action", LocalResourceFile)));
confirmDeleteScriptBuilder.Append(" });\r\n");
confirmDeleteScriptBuilder.Append("});\r\n");
if (!(Page.ClientScript.IsStartupScriptRegistered("ConfirmDeleteScript")))
Page.ClientScript.RegisterStartupScript(GetType(), "ConfirmDeleteScript", confirmDeleteScriptBuilder.ToString(), true);
If anyone wonders about the amount of backslashes: the escape sequence for \ is \\, and the Javascript needs \\\' for ', and in a string in C# this is getting \\\\\\\' - three backslashes and one ' :-)
Any less complicated way to achieve this would be appreciated...
Happy DNNing
Michael