2015-11-11 22 views
1

我剛剛在我的模塊開發中遇到了這個問題,我需要問這個問題給一些專家。 我的問題是,根據自定義字段I在配置文件屬性中提供的值,可能是在DNN7中顯示和取消顯示模塊的(最佳)方式。 我需要像這樣:如何顯示和UnShow DNN模塊

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

這怎麼能實現?

感謝,

回答

2

你可以做最簡單的事情是環繞你的模塊視圖的HTML內容的面板。

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

... 

</asp:Panel> 
在你的模塊視圖的代碼隱藏

然後,做這樣的事情:

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); 
    } 
} 
+0

哦,我從來沒有想到,這將是剛剛可見= true或false雖然我還沒有」嘗試這一尚未,因爲它是一個模塊,所以我認爲我應該做些什麼。我的錯!謝了哥們。 – OneLazy