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.0Unset object reference errorUnset object reference error
Previous
 
Next
New Post
8/10/2007 12:30 PM
 

I am running DNN 4.5.1, and have written a form as part of a module I am developing. When I submit the form, there is a C# method that attempts to read the field values. There is an error on the first field that says "object reference not set to an instance of an object." What am I missing here? Clicking the "Cancel" button works.

The form looks like this (with most fields omitted):

<%@ Control Language="C#" Inherits="MyForm"
    CodeFile="MyForm.ascx.cs" AutoEventWireup="false" Explicit="True" %>
<%@ Register TagPrefix="dnn" Assembly="DotNetNuke" Namespace="DotNetNuke.UI.WebControls"%>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %> <br />
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<table cellspacing="2" cellpadding="4" border="0">
    <tr valign="top">
        <td class="SubHead">
            <dnn:label id="plName" runat="server" controlname="txtName" suffix=":"></dnn:label>
            <asp:textbox id="txtName" runat="server" cssclass="NormalTextBox" columns="35"
                maxlength="100"></asp:textbox>
        </td>
    </tr>
    <tr valign="top">
        <td align="center">
            <asp:linkbutton id="InsertButton" commandname="Insert" ValidationGroup="MyForm"
                runat="server" cssclass="CommandButton" causesvalidation="True"
                OnClick="InsertButton_Click">Submit</asp:linkbutton>
            &nbsp;
            <asp:linkbutton id="CancelButton" CommandName="Cancel" ValidationGroup="MyForm"
                runat="server" cssclass="CommandButton" causesvalidation="False"
                OnClick="CancelButton_Click">Cancel</asp:linkbutton>
        </td>
    </tr>
</table>

The two handler methods are:

protected void CancelButton_Click(Object sender, EventArgs e)
{
    txtName.Text = UserInfo.DisplayName;
    // Clear out other fields.
}

protected void InsertButton_Click(Object sender, EventArgs e)
{
    String name;
    PortalSecurity sec;

    sec = new PortalSecurity();
    info.Comment = sec.InputFilter( sec.InputFilter( txtDescription.Text,
        PortalSecurity.FilterFlag.NoScripting ), PortalSecurity.FilterFlag.NoSQL );
    // Get data from other fields.
}

 
New Post
8/11/2007 2:40 PM
 

I have found the cause of the error soon after making the post above. The info object was not instantiated in the constructor. After I instantiated it there, the error message disappeared.

 
New Post
8/11/2007 10:37 PM
 

what is " info.Comment" ? Is that where you're getting the error? Where and how is that object initialized?



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Unset object reference errorUnset object reference error


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