DotNetNuke URL DNN中的链接

     DotNetNuke 模块包含一组用户控件(*.ascx 文件),他们都定义在“模块定义”(module definition)中。如果你查看DNN 源码,你会发现多数模块都包含 View Edit Setting 3个控件,这也是模块默认的3 个控件。查看这3 个控件之间的跳转代码,通常如下所示:

View controlEdit control 导航跳转的时候如下代码:

Response.Redirect(EditUrl())

Edit controlView control 导航跳转如下代码:

Response.Redirect(Globals.NavigateURL(), true)

You usually don't need a link for the Settings control. You simply configure the User Control in the module definition as a Settings control and a link is automatically created in the module's menu to navigate to it.

使用DNN中的导航方法 NavigateURL()

如下代码示例,点击按钮跳转

protected void cmdEdit_Click(object sender, EventArgs e)
{
  Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "mygallery", "mid=" + ModuleId.ToString()));
}

这段代码将创建如下链接:

http://localhost/MyDNNWebsite/Home/tabid/36/ctl/mygallery/mid/362/Default.aspx

NavigateURL 方法第一个参数是跳转的页面,第二个参数是module definition 中control key 的名字,第三个参数是moduleID 。

注意:这样产生的连接,调转后页面只会加载模块的一个控件,即跳转后你只能在页面上看模块的一个控件,页面上其他模块都不会加载。通常我们都只需要当前模块发生跳转,页面上其他的模块都还是在页面上正常显示的,如果需要同时能看到其他模块,我们可以用如下办法:

1) View Control 作为容器,容器中加载其他控件

2) 需要加载到 View 中的页面都不需要定义为 Module Control

View 中示例代码如下:

protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            string token = Request["token"];
            string page = ResolveUrl(this.TemplateSourceDirectory + "/List.ascx");
            switch (token)
            {
                case "detail":
                    page = ResolveUrl(this.TemplateSourceDirectory + "/Detail.ascx");
                    break;
                case "new":
                    page = ResolveUrl(this.TemplateSourceDirectory + "/CreateNew.ascx");
                    break;
                default:
                    break;
            }

            PortalModuleBase objModule = (PortalModuleBase)LoadControl(page);
            objModule.ModuleConfiguration = this.ModuleConfiguration;
            this.Controls.Add(objModule);

        }

例如要调整到 Detail.ascx ,代码如下:

Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "token=new"));

posted @ 2009-06-07 14:51  炽焰惊鸿  阅读(388)  评论(0编辑  收藏  举报