在DNN中可以添加一个ModuleAction
菜单项。根据DNN网站上的this article,甚至可以在服务器端进行一些额外的处理。将代码转换为C#后,ActionHandler
永远不会被调用。DotNetNuke ModuleAction服务器端处理
这是我的代码:
public ModuleActionCollection ModuleActions
{
get
{
ModuleActionCollection Actions = new ModuleActionCollection();
ModuleAction urlEventAction = new ModuleAction(ModuleContext.GetNextActionID());
urlEventAction.Title = "Action Event Example";
urlEventAction.CommandName = "redirect";
urlEventAction.CommandArgument = "cancel";
urlEventAction.Url = "http://dotnetnuke.com";
urlEventAction.UseActionEvent = true;
urlEventAction.Secure = DotNetNuke.Security.SecurityAccessLevel.Admin;
Actions.Add(urlEventAction);
return Actions;
}
}
private void MyActions_Click(object sender, DotNetNuke.Entities.Modules.Actions.ActionEventArgs e)
{
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, string.Format(Localization.GetString("ClickMessage", LocalResourceFile), e.Action.CommandName), ModuleMessage.ModuleMessageType.BlueInfo);
switch (e.Action.CommandName.ToUpper())
{
case "REDIRECT":
if (e.Action.CommandArgument.ToUpper() != "CANCEL")
{
Response.Redirect(e.Action.Url);
}
else
{
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Canceled the Redirect", ModuleMessage.ModuleMessageType.YellowWarning);
}
break;
}
}
,并在页面初始化附上事件处理程序:
AddActionHandler(new ActionEventHandler(MyActions_Click));
我也尝试在网页加载安装由DNN源本身来完成。 显示菜单项并执行到http://dotnetnuke.com的重定向。 但我的断点MyActions_Click
从未被击中。
我在做什么错?
我在DotNetNuke 7.1中运行,模块引用DNN 6.2。
嘿利,清除了缓存,重新启动应用程序池,重置IIS,没有任何帮助。我用'IPostBackEventHandler'发现了另一种方式,但喜欢使用DNN方式,它具有更多功能... – jerone