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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Calling a sub via AddContent Module ActionCalling a sub via AddContent Module Action
Previous
 
Next
New Post
3/21/2008 9:06 PM
 

Greetings all... I've been messing with this for two days now and I'm about to give up. I'm trying to build a module that calls a custom VB subroutine to do the setup for adding a record instead of redirecting using EditURL() and I can't seem to get it right. I've looked for documentation on the various overloads but came up empty.

Following the lead on a post to someone who wanted to call javascript from a module action I came up with the following but it doesn't work. It tries redirecting to a control called "cmdAddRecord" instead of calling the subroutine.

Perhaps I need to abandon the Module Action all together gut I figured I would check will all the DNN gurus out there first . 

Any recommendations would be greatly appreciated.  If you look below, "cmdAddRecord" is the subroutine I want to call when Add Record it clicked.

Chuck R.

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
      Get
        Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
        Actions.Add(GetNextActionID, _
          Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), _
          Entities.Modules.Actions.ModuleActionType.AddContent, _
          "", "", "cmdAddRecord", False, _
          Security.SecurityAccessLevel.Edit, True, False)
        Return Actions
      End Get

 

P.S.  Thanks to Mitchel Sellers for his code colorizers.  Great Resource Mitch!

 
New Post
3/22/2008 12:48 AM
 

I guess I should have given it a little more time...  After posting the above I remembered I have the WROX Publishing "Professional DotNetNuke 4" book.  I dug it out and sure enough, Chapter 8 covers all of the Core DNN APIs including IActionable.  All the info I needed was right there in Chapter 8.  Needless to say this book is staying right on my desk!!! 

It was very interesting reading the background info on the IActionable interface.  Basically, the menu and module are two distinct and seperate objects.  Both are children of the module container.  Because they are seperate objects they know nothing about each other -- there is no direct reference between them.  This isn't normally a problem because most of the time they don't need to know about each other.  Mostly the menu items handle redirecting the user to the page/module they need and that's it.  However when you do need to communicate directly between the module and the menu you have to communicate through a "Mediator".  This is the part I was missing.  The chapter details the "Mediator Design Pattern" and in DNN the Skin performs the mediation between the two.  The book explained that in your module you write an event handler to process all menu actions.  Then in the Page_Load of your module you use a method in the Skin class to register your event handler.  Once you do this, all menu events that are raised in your module get passed through your event handler.  You handle the menu actions that you need to and pass on any others. 

For anyone interested below is the code that made my evening...  Note that the RegisterActionMenuHandler is called from the Page_Load.

 

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    Public Sub RegisterActionMenuHandler()
      '-- Register Action Menu Handler: Since we want to short-circuit the Add Content Module Action
      '-- so we can use the modal popup we need to register our own event handler.  There may very
      '-- well be a better way to accomplish this but I spent a lot of time researching and didn't
      '-- find much.  I found this in Chapter 8 of the "Professional DotNetNuke 4" book from WROX
      '-- publishing.  I hope this works...

      '-- Get a reference to the containing skin (the skin is the "Mediator" for Menu <--> Module
      '-- communication).
      Dim ParentSkin As UI.Skins.Skin = UI.Skins.Skin.GetParentSkin(Me)

      If Not (ParentSkin Is Nothing) Then
        '-- Register event handler on the parent skin so it can tell us when a menu has been clicked.
        ParentSkin.RegisterModuleActionEvent(Me.ModuleId, AddressOf ModuleAction_Click)
      End If

    End Sub

    Public Sub ModuleAction_Click(ByVal sender As Object, ByVal e As Entities.Modules.Actions.ActionEventArgs)
      '-- Check for the Add Conent Action as this is the action we want to handle ourself. For anything else
      '-- we just send it off wherever it would have gone if we let the core handle it.
      If e.Action.CommandName = Entities.Modules.Actions.ModuleActionType.AddContent Then
        cmdAddRecord()
      ElseIf e.Action.Url.Length > 0 Then
        Response.Redirect(e.Action.Url, True)
      End If
    End Sub

 

I hope this is helpfull to some others out there.  This one little tidbit has more than paid for the cost of the book.  I highly recommend it to anyone doing DNN development!!!!

Chuck R.

P.S. It's very late so please forgive any seplling/grammar errors :-)

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Calling a sub via AddContent Module ActionCalling a sub via AddContent Module Action


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