如何创建容器外观以使其标题仅在编辑和布局模式下显示?
我知道我可以在页面设置中设置show-container:false ...但我真的不必为安装我的容器外观的整个网站上的所有页面设置此项。
答案 0 :(得分:2)
这是DNN4,我没有写它,但这是从我们的容器中撕掉的代码。我会让你一路走来,决定你不需要哪些部分:
以下是容器的ascx文件中的行...
<DNN:DNNToolBar id="tbEIPTitle" runat="server" CssClass="eipbackimg" ReuseToolbar="true">...
和来自ascx.vb文件的代码......
Private Function CanEditModule() As Boolean
Dim blnCanEdit As Boolean = False
Dim objModule As Entities.Modules.PortalModuleBase = Container.GetPortalModuleBase(Me)
If (Not objModule Is Nothing) AndAlso (objModule.ModuleId > Null.NullInteger) Then
blnCanEdit = (PortalSettings.UserMode = PortalSettings.Mode.Edit)
AndAlso (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName)
OrElse PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString))
AndAlso (IsAdminControl() = False)
AndAlso (PortalSettings.ActiveTab.IsAdminTab = False)
End If
Return blnCanEdit
End Function
和...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
If CanEditModule() = False OrElse Entities.Portals.PortalSettings.GetSiteSetting(objPortalModule.PortalId, "InlineEditorEnabled") = "False" Then
lblTitle.EditEnabled = False
tbEIPTitle.Visible = False
....