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...Building ExtensionsBuilding ExtensionsModulesModulesObject not set issueObject not set issue
Previous
 
Next
New Post
3/19/2013 11:47 AM
 

Having a go at my first ever module which works fine in my developement area on PC through a localhost but then when added to website falls over when hitting the submit button. Lots of code coming up, hoping someone can help while I still have hair left.

Events.ascx

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Event.ascx.vb" Inherits="Categories.Events" EnableViewState="false" %>
<%@ Register TagPrefix="dnnui" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %>


<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label id="lbla" runat="server" Text="Nothing happened" />
<fieldset>

    <legend>Add an event</legend>

    <div class="control-group">
    <label>Event Name</label>
    <asp:textbox ID="txtEventName" runat="server" placeholder="Event Name" />
    
    <asp:Label ID="Label1" runat="server" CssClass="control-label" AssociatedControlID="StartDatePicker" Text="Start date" />
        <div class="controls">
            <dnnui:DnnDatePicker runat="server" ID="StartDatePicker" />
            <dnnui:DnnTimePicker runat="server" ID="StartTimePicker" />
        </div>
    
    <asp:Label ID="Label2" runat="server" CssClass="control-label" AssociatedControlID="FinishDatePicker" Text="Finish date" />
        <div class="controls">
             <dnnui:DnnDatePicker runat="server" ID="FinishDatePicker" />
            <dnnui:DnnTimePicker runat="server" ID="FinishTimePicker" />
            </div>
    </div>

    <asp:Label ID="Label3" runat="server" CssClass="control-label" Text="Location" />
    <div class="controls">
        <asp:TextBox runat="server" id="txtLocation" placeholder="Location" />
    </div>

    <asp:Label ID="Label4" runat="server" CssClass="control-label" Text="Description" />
    <div class="controls">
        <asp:TextBox runat="server" id="txtDescription" MaxLength="500" TextMode="MultiLine" Width="100%" />
    </div>
    </div>
</fieldset>
</ContentTemplate>
<Triggers>
    <asp:PostBackTrigger ControlID="btnAddEvent" />
</Triggers>
</asp:UpdatePanel>
<asp:LinkButton CssClass="btn btn-info" runat="server" ID="btnAddEvent" Text="Add Your Event"  />

Events.vb.ascx

Imports System
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Modules.Events

Namespace Categories
    Partial Class Events
        Inherits PortalModuleBase
        

        Protected Sub AddEvent()

            Dim ev As New Modules.Events.EventInfo
            With ev
                .EventID = -1
                .ModuleID = 474
                .EventTimeBegin = "2013-03-23 09:00:00.000"
                .Duration = 100
                .EventName = "Marks Test Event"
                .EventDesc = "My program tester"
                .Importance = EventInfo.Priority.Medium
                .Reminder = "You requested reminding about the following Event:<br />" & _
                    "<br />[event:title]<br /><br />on [NOTALLDAYEVENT][event:startdate][/NOTALLDAYEVENT][ALLDAYEVENT][event:startdate|D][/ALLDAYEVENT] [event:timezone]<br />" & _
                    "to [NOTALLDAYEVENT][event:enddate][/NOTALLDAYEVENT][ALLDAYEVENT][event:enddate|D][/ALLDAYEVENT]<br />[event:description]"
                .Notify = "Event Reminder: [event:title] on [NOTALLDAYEVENT][event:startdate][/NOTALLDAYEVENT][ALLDAYEVENT][event:startdate|D][/ALLDAYEVENT]"
                .CreatedByID = UserId
                .Approved = False
                .PortalID = PortalId
                .Signups = False
                .MaxEnrollment = 0
                .EnrollRoleID = 0
                .EnrollFee = 0
                .EnrollType = "FREE"
                .PayPalAccount = "host@paypal.com"
                .Cancelled = False
                .ImageURL = ""
                .ImageType = ""
                .ImageWidth = 0
                .ImageHeight = 0
                .ImageDisplay = False
                .SendReminder = True
                .ReminderTime = 24
                .ReminderTimeMeasurement = "h"
                .ReminderFrom = "info@elycity.co.uk"
                .SearchSubmitted = False
                .CustomField1 = ""
                .CustomField2 = ""
                .OriginalDateBegin = "2013-03-23 09:00:00.000"
                .LastUpdatedID = UserId
                .OwnerID = UserId
                .EnrollListView = False
                .NewEventEmailSent = False
                .DisplayEndDate = True
                .AllDayEvent = False
                .DetailPage = False
                .DetailURL = ""
                .DetailNewWin = False
                .AllowAnonEnroll = False
                .ContentItemID = 0
                .JournalItem = True
                .Summary = Nothing


                Dim eli As New EventLocationController
                .Location = eli.EventsLocationGet(1, PortalId).Location

                Dim eci As New EventCategoryController
                .Category = eci.EventCategoryGet(1, PortalId).Category

                Dim ri As New EventRecurMasterInfo
                With ri
                    .RecurMasterID = -1
                    .ModuleID = ModuleId
                    .PortalID = PortalId
                    .RRULE = ""
                    .DTSTART = ev.EventTimeBegin
                    .Duration = CType(ev.Duration, String) + "M"
                    .Until = ev.EventTimeBegin
                    .EventName = ev.EventName
                    .EventDesc = ev.EventDesc
                    .Importance = CType(ev.Importance, EventRecurMasterInfo.Priority)
                    .Reminder = ev.Reminder
                    .Notify = ev.Notify
                    .Approved = ev.Approved
                    .Signups = ev.Signups
                    .MaxEnrollment = ev.MaxEnrollment
                    .EnrollRoleID = ev.EnrollRoleID
                    .EnrollFee = ev.EnrollFee
                    .EnrollType = ev.EnrollType
                    .PayPalAccount = ev.PayPalAccount
                    .ImageURL = ev.ImageURL
                    .ImageType = ev.ImageType
                    .ImageWidth = ev.ImageWidth
                    .ImageHeight = ev.ImageHeight
                    .ImageDisplay = ev.ImageDisplay
                    .Location = ev.Location
                    .Category = ev.Category
                    .SendReminder = ev.SendReminder
                    .ReminderTime = ev.ReminderTime
                    .ReminderTimeMeasurement = ev.ReminderTimeMeasurement
                    .ReminderFrom = ev.ReminderFrom
                    .CustomField1 = ev.CustomField1
                    .CustomField2 = ev.CustomField2
                    .EnrollListView = ev.EnrollListView
                    .DisplayEndDate = ev.DisplayEndDate
                    .AllDayEvent = ev.AllDayEvent
                    .OwnerID = ev.OwnerID
                    .CreatedByID = ev.CreatedByID
                    .UpdatedByID = ev.LastUpdatedID
                    .DetailPage = ev.DetailPage
                    .DetailURL = ev.DetailURL
                    .DetailNewWin = ev.DetailNewWin
                    .EventTimeZoneId = TimeZone.CurrentTimeZone.StandardName
                    .AllowAnonEnroll = ev.AllowAnonEnroll
                    .ContentItemID = ev.ContentItemID
                    .SocialGroupID = 0
                    .SocialUserID = 0
                    .Summary = ev.Summary
                    .CultureName = "en-GB"
                End With

                Dim rc As New EventRecurMasterController
                .RecurMasterID = rc.EventsRecurMasterSave(ri).RecurMasterID

            End With

            Dim a As New Modules.Events.EventController
            a.EventsSave(ev, False)

            lbla.Text = "It ran"
        End Sub

        Public Sub CreateEvent() Handles btnAddEvent.Click
            AddEvent()
        End Sub


       


        'If Not IsPostBack Then
        '    Dim lst As New List(Of Item)()

        '    Dim ec As New EventCategoryController
        '    Dim el As EventCategoryInfo
        '    For Each el In ec.EventsCategoryList(0)

        '        lst.Add(New Item() With { _
        '        .ID = el.Category, _
        '        .Val = el.CategoryName _
        '    })

        '    Next
        '    ddlTest.DataSource = lst
        '    ddlTest.DataTextField = "Val"
        '    ddlTest.DataValueField = "ID"
        '    ddlTest.DataBind()
        'End If

      

    End Class

    Class Item
        Private _val As String
        Private _id As String

        Public Property ID() As String
            Get
                Return _id
            End Get
            Set(value As String)
                _id = value
            End Set
        End Property
        Public Property Val() As String
            Get
                Return _val
            End Get
            Set(value As String)
                _val = value
            End Set
        End Property


    End Class
End Namespace


Please note there are some commented code, I am also experimenting with some jquery

The full issue:

AssemblyVersion: 7.0.3

PortalID: 0

PortalName: The City of Ely Website

UserID: 3

UserName: Facebook-567221822

ActiveTabID: 117

ActiveTabName: Add Event

RawURL: /Thingstodo/AddEvent.aspx

AbsoluteURL: /Default.aspx

AbsoluteURLReferrer: http://www.elycity.co.uk/Thingstodo/AddEvent.aspx

UserAgent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22

DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke

ExceptionGUID: 1a89c3c5-9166-48c9-b699-6b35d58c7e59

InnerException: Object reference not set to an instance of an object.

FileName:

FileLineNumber: 0

FileColumnNumber: 0

Method: Categories.Events.AddEvent

StackTrace:

Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Categories.Events.AddEvent() at Categories.Events._Lambda$__1(Object a0, EventArgs a1) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---

Source:

Server Name: WEBSERVER

 

Sorry, lot to take in, but if anyone has the answer as to why its not working on my website but is fine on development PC then please let me know.

Oh, just incase the question comes, both are on 7.0.3 and both use events 6.1.1



Mark Cooney
Programmer
Ely, Cambridgeshire
07767150058
CambsCreative
mark@cambscreative.co.uk

Visit Ely City Website
 
New Post
3/24/2013 11:54 AM
 
It could be any of these statements:

Dim eli As New EventLocationController
.Location = eli.EventsLocationGet(1, PortalId).Location

Dim eci As New EventCategoryController
.Category = eci.EventCategoryGet(1, PortalId).Category

Dim rc As New EventRecurMasterController
.RecurMasterID = rc.EventsRecurMasterSave(ri).RecurMasterID

All of these look like you are making a database call and assuming that the result from that database call an object. What if that object does not exist?

What I would do would be something like this:
(in pseudocode)

Dim eli As New EventLocationController
Dim eventLocation as Object = eli.EventsLocationGet(1, PortalId)
If eventLocation is not Nothing then
.Location = eventLocation.Location
else
'handle the case when this object does not exist.
end if

Hristo Evtimov
www.packflash.com
 
New Post
3/24/2013 12:20 PM
 
That was exactly the issue!! I did resolve and sorry for not making it known.

Thanks Hristo

Mark Cooney
Programmer
Ely, Cambridgeshire
07767150058
CambsCreative
mark@cambscreative.co.uk

Visit Ely City Website
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesObject not set issueObject not set issue


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