C# DotNetNuke模块操作服务器端处理
在DNN中,可以添加C# DotNetNuke模块操作服务器端处理,c#,dotnetnuke,dotnetnuke-module,C#,Dotnetnuke,Dotnetnuke Module,在DNN中,可以添加ModuleAction菜单项。根据DNN站点,甚至可以在服务器端执行一些额外的处理。将代码转换为C#后,永远不会调用ActionHandler 这是我的代码: public ModuleActionCollection ModuleActions { get { ModuleActionCollection Actions = new ModuleActionCollection(); ModuleAction urlEven
ModuleAction
菜单项。根据DNN站点,甚至可以在服务器端执行一些额外的处理。将代码转换为C#后,永远不会调用ActionHandler
这是我的代码:
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;
}
}
在页面init中,我附加了事件处理程序:
AddActionHandler(new ActionEventHandler(MyActions_Click));
我还尝试了像DNN源代码本身那样在页面加载中附加内容。
将显示菜单项并执行重定向到。
但是我在MyActions\u Click
中的断点从未命中
我做错了什么?
我运行的是DotNetNuke 7.1,模块参考了DNN 6.2。我真的认为这不是DNN问题。我会清除你的临时缓存并再次尝试调试
Leigh我的解决方案使用
IPostBackEventHandler
而不是DNN方式(直到有人纠正我):
别忘了在页面类名中添加IPostBackEventHandler
命名空间:
使用System.Web.UI代码>嘿,Leigh,清除我的缓存,重新启动应用程序池,重置iis,没有任何帮助。我用IPostBackEventHandler
找到了另一种解决方法,但我喜欢使用DNN方式,它有更多的功能。。。
public ModuleActionCollection ModuleActions
{
get
{
ModuleActionCollection Actions = new ModuleActionCollection();
Actions.Add(ModuleContext.GetNextActionID(),
"Bla",
"",
"",
"",
"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "ARGUMENT"),
Page.ClientScript.GetPostBackEventReference(this, "ARGUMENT"),
false,
DotNetNuke.Security.SecurityAccessLevel.Edit,
true,
false);
return Actions;
}
}
public void RaisePostBackEvent(String eventArgument)
{
if (eventArgument.ToUpper() == "ARGUMENT")
{
...
Globals.Redirect(HttpContext.Current.Request.RawUrl, false);
}
}