Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Hide HTML Elements Based On Edit StateHide HTML Elements Based On Edit State
Previous
 
Next
New Post
8/21/2008 7:08 PM
 

Okay - I am new to DNN but am an experienced .NETer.

What I am looking to do is hide certain elements (table/div) in my custom container based on which state the page is in - View, Edit, or Design.

In my containers I have all the edit elements in a separate section of the container and want to set the visibility to false if the state of the page is in "View" or a user isn't logged in.

Many Thanks in Advance,

J

P.S. I searched for this issue and couldn't find anything so I appoligize if there is already and answer out there.

 

 

 

 
New Post
9/25/2008 7:48 AM
 

Hi.

This might not be the best way to do it, but it solves the problem of detecting edit mode in a container:

<asp:Panel ID="Panel1" runat="server" Style='<%# DotNetNuke.UI.Containers.Container.GetPortalModuleBase( this ).IsEditable ? "display:block;": "display:none;" %>'>
... HTML you want to hide, like tables/divs which only contains: <dnn:SOLPARTACTIONS runat="server" ID="dnnSOLPARTACTIONS" /> ..
</asp:Panel>

Oh yeah, I am a C# programmer and have no clue how to write the above in visual basic, so in order to use this you need to change the first line of the .aspx file (this of cause only works if you edit the .aspx file directly and do not parsed html files for the container):

<%@ Control Language="c#" Codebehind="~/admin/Containers/container.vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Containers.Container" %>

As I said - probably not the best solution, but it works

 

Best of luck to you!

Allan K.

 

 
New Post
9/25/2008 9:03 AM
 

The usual DNN approach is to place your view and edit controls (elements) in a module control or skin object not in the container itself as the container simply defines the visual appearance of the area surrounding your module and includes such objects such as the module title, action menu, print/rss icon, etc.

Module controls must inherit from the base class PortalModuleBase which includes a definition for the property IsEditable. Since IsEditable will return false when the state of the page is in View mode and when edit permission has not been granted to the user's role(s) in the module settings, this checking of page state and permission has been taken care of for you.

In your module control's markup you could set the Visible attribute of an Asp.Net control that will be databound as follows:

Visible='<%# IsEditable() %>'

or in the codebehind:

tbName.Visible = IsEditable()

If you must add edit controls directly to your container (which I don't recomend and have never tried), you could obtain a reference to the contained module using the static method defined in the Container class and define your own IsEditable method as follows:

Public Function IsEditable() As Boolean
    Dim myModule As PortalModuleBase = GetPortalModuleBase(Me)
    If myModule Is Nothing Then
         Return False
    Else
         Return myModule.IsEditable()
    End If
End Function

 


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
12/19/2008 11:04 AM
 

Hi,

Quite useful solution, but is it possible to expand this with an option to hide module in view mode only if it's empty (has no content)?

Cheers
Ivan

 
New Post
12/19/2008 6:22 PM
 

I did just that in my ContentDejour module available in the DNN Forge. PortalModuleBase from which your module's view control will inherit provides a Public ReadOnly Property ContainerControl by which the module container may be referenced. Here is a bit of code from the view control's Page_Load handler:

If itemCount = -1 Then
    If MyConfiguration.HideWhenNoContent AndAlso Not IsEditable Then
          ContainerControl.Visible = False
    Else
          divContent.InnerHtml = Localization.GetString("NO_CONTENT", MyConfiguration.LocalSharedResourceFile)
    End If
Else
    'display the content
End If

In preceeding code, itemCount is set to -1 to signify that there was no content to be shown. I also implemented a HideWhenNoContent setting for the module so that the administrator could choose between hiding the module or displaying a localized message when there was no content.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Hide HTML Elements Based On Edit StateHide HTML Elements Based On Edit State


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out