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.0CanCan't get ModuleID
Previous
 
Next
New Post
2/20/2008 2:37 PM
 

I am working on a version of the Events Module in which I am trying to make categories available on a per module basis. If there are multiple instances of the module used then the categories are unique to each module.

In the core Events module categories are on a per Portal basis.

SelectCategory Page Load:

            Dim ctrlEventCategories As New EventCategoryController
            Dim lstCategories As ArrayList = ctrlEventCategories.EventsCategoryList(PortalId)
            Me.ddlCategories.DataSource = lstCategories

I am using the same SelectCategory.ascx control and am trying to modify it to select on the basis of PortalID and ModuleID. The difficulty I have is that while the PortalID is available at PageLoad in SelectCategory.ascx ModuleID has a value of -1.

Tracing I can see that the ModuleID is valid at PageLoad of my parent ascx. When the PageLoad sub ends for the parent page the PageLoad sub begins for the SelectCategory.ascx but at this point ModuleID has a value of -1.

I have tried storing the value in a property of the base class but I still endup with -1.

 

Parent ascx:

Namespace SimpleEvents

Partial Public Class SimpleEventMonth
        Inherits SimpleEvents.SimpleEventBase

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            log4net.Config.XmlConfigurator.Configure()
            log.Debug("Page Load")
            log.Debug("ModuleID: " & ModuleId.ToString)   '---------------  ModuleID is valid here
            Try
                CurrentModuleID = ModuleId  ' Sore in base class property

. . .

End Sub

 

SelectCategory.ascx

Namespace SimpleEvents

    Partial Public Class SimpleEventSelectCategory
        Inherits SimpleEvents.SimpleEventBase

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                log4net.Config.XmlConfigurator.Configure()
                log.Debug("Page Load")

                If Not Page.IsPostBack Then

                    log.Debug("ModuleID: " & ModuleId.ToString)        '--------------------- ModuleID has a value of -1 here but PortalID seems valid at 0

. . .

 Any thoughts?

Declan


 
New Post
2/20/2008 6:51 PM
 

Declan,

I know of a solution, not saying it is the best solution, so people please speak up if you got a better way I am all ears.

Just call this function sending in the variable  "Me.UniqueID" like so on your user control that is inside a parent user control.

ParentModuleID = GetModuleIDFromParent(Me.UniqueID)

Here it is: 


Shared Function GetModuleIDFromParent(ByVal myUniqueID As String) As Integer
            'assumes format like this "dnn$ct1234$ModuleParentName$ModuleName" and it grabs the number portion
            Dim intResult As Integer
            Dim strArray As String()
            Try
                '--For 3.x and 4.x Compatablity
                If myUniqueID.IndexOf(":") > -1 Then
                    ' DNN 3.X
                    strArray = myUniqueID.Split(":")
                Else
                    ' DNN 4.X
                    strArray = myUniqueID.Split("$")
                End If
                intResult = CType(strArray(1).Remove(0, 3), Integer)
            Catch ex As Exception
                intResult = 0
            End Try

            Return intResult
        End Function
 
New Post
2/21/2008 12:05 AM
 

Since SelectCategory.ascx.vb inherits from PortalModuleBase it has a ModuleConfiguration (from which its ModuleID property would be accessed). Apparently this is not being initialized in the parent control (EventMonth.ascx).  So, what happens if in Page_Load of the parent control (EventMonth.ascx.vb) you add the following statement:

Me.SelectCategory.ModuleConfiguration = Me.ModuleConfiguration

Also, don't forget that you'll have to implement the use of ModuleID in all other controls and components as well as the appropriate stored procedures that retrieve, create, and update event categories.  You might also want to consider implementing what I did for handling categories in one custom module I wrote - consider a ModuleID of -1 as a marker for "global" categories available for any instance of the module within the portal.


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
2/21/2008 4:22 AM
 

William Severance wrote

Me.SelectCategory.ModuleConfiguration = Me.ModuleConfiguration

Thanks Bill, that solved it[:)]

William Severance wrote

Also, don't forget that you'll have to implement the use of ModuleID in all other controls and components as well as the appropriate stored procedures that retrieve, create, and update event categories.  You might also want to consider implementing what I did for handling categories in one custom module I wrote - consider a ModuleID of -1 as a marker for "global" categories available for any instance of the module within the portal.

FYI:  I use Entity Spaces which generates all my code access classes and my stored procedures. If I have to change a table I just run the Entity Spaces template again and all my code and stored procs will be regenerated for me. SImple!

All I need in my module to populate the categories drop down is:

Dim collCategories As New SimpleEventsCategoryCollection
With collCategories
    .Query.Select(.Query.CategoryID, .Query.CategoryName)
    .Query.Where(.Query.PortalID.Equal(PortalId), .Query.ModuleID.Equal(ModuleId))
     .Query.Load()
End With

Me.ddlCategories.DataSource = collCategories

I could use an SP but in this instance it's not needed.

Declan


 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0CanCan't get ModuleID


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