简体   繁体   English

如何显示和取消显示DNN模块

[英]How to Show And UnShow DNN module

I just got off to this problem in my module development where I needed to ask this to some expert. 我只是在我的模块开发中遇到了这个问题,我需要问一些专家。 My question is, what could be the (best) way of showing and unshowing module in DNN7 depending on the value of custom field I provided in profile properties. 我的问题是,根据我在配置文件属性中提供的自定义字段的值,DNN7中显示和取消显示模块的(最佳)方法是什么? I need something like: 我需要类似的东西:

if(customfield == "somevalue")
{
    module1.show;
}

how can this be achieved? 如何做到这一点?

thanks, 谢谢,

The easiest thing you can do is wrap a panel around your module view's html content. 您可以做的最简单的事情是在模块视图的html内容周围包装一个面板。

<asp:Panel ID="pnlModuleContainer" runat="server">

...

</asp:Panel>

Then in your module view's codebehind, do something like this: 然后在您的模块视图的代码中,执行以下操作:

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        pnlModuleContainer.Visible = false;
        if (User.Profile.GetPropertyValue("CustomFieldName") == "somevalue")
        {
            pnlModuleContainer.Visible = true;
        }
        else
        {
            DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "You need 'somevalue' to see this module",
                        DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.BlueInfo);
        }
    }
    catch (Exception exc) //Module failed to load
    {
        Exceptions.ProcessModuleLoadException(this, exc);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM