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>
<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.
}