473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.NullReferenceException on TextBox object...

Hello,

I am trying to set up a panel that appears on a page that prompts a user
to enter in a note. This panel object is initially invisable and appears
when the user clicks on a button. Contained within the panel are a couple
of buttons and a textbox. Code is as follows:

ASPX page:
---------

<%@ Page Language="VB" Inherits="CustProfile" Src="CustProfile.vb"
autoeventwireup="False" %>
<html>
<form>
....

<td align="middle">
<asp:Button id="btnAddNote" runat="server" Text="Add New
Note"></asp:Button>
</td>
....

<asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid; BORDER-TOP:
black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
265px" runat="server" Width="360px" Visible="False" HorizontalAlign="Left">
<p>
<strong>Add Note:</strong>
</p>
<p align="center">
<asp:TextBox id="txAddNote" runat="server" Columns="35"
AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnSaveNote" runat="server" Text="Save Note"
Enabled="True" Visible="True"></asp:Button>
&nbsp;
<asp:Button id="btnCancelNote" runat="server" Text="Cancel"
Enabled="True" Visible="True"></asp:Button>
<br />
<br />
</p>
</asp:Panel>
....
</form>
</html>
VB code:
-------
Imports ...

Public Class CustProfile
'For PostBack
Inherits Page

Protected txtAddNote as TextBox
Protected pnlAddNote as Panel
Protected WithEvents btnAddNote as Button
....

Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
btnAddNote.Click
txtAddNote.Text = ""
pnlAddNote.Visible = True
End Sub

....
End Class
And this is the error message I get which makes no sense to me because the
object is declared and exists in both files.

Browser Msg:
-----------

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Click(source as Object, e as EventArgs)
Handles btnAddNote.Click
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visible = True
Line 426: End Sub

Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424

If anyone can shed some light on this subject (namely point out what I'm
doing wrong) it would be greatly appreciated.

A. Nonymous (slightly dazed and confused)
Nov 19 '05 #1
2 2429
Please disregard this post.

I think I've found a way using JavaScript.
"A. Nonymous" <an*******@hotmail.com> wrote in message
news:2P********************@giganews.com...
Hello,

I am trying to set up a panel that appears on a page that prompts a user to enter in a note. This panel object is initially invisable and appears
when the user clicks on a button. Contained within the panel are a couple
of buttons and a textbox. Code is as follows:

ASPX page:
---------

<%@ Page Language="VB" Inherits="CustProfile" Src="CustProfile.vb"
autoeventwireup="False" %>
<html>
<form>
...

<td align="middle">
<asp:Button id="btnAddNote" runat="server" Text="Add New
Note"></asp:Button>
</td>
...

<asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
265px" runat="server" Width="360px" Visible="False" HorizontalAlign="Left"> <p>
<strong>Add Note:</strong>
</p>
<p align="center">
<asp:TextBox id="txAddNote" runat="server" Columns="35"
AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnSaveNote" runat="server" Text="Save Note" Enabled="True" Visible="True"></asp:Button>
&nbsp;
<asp:Button id="btnCancelNote" runat="server" Text="Cancel" Enabled="True" Visible="True"></asp:Button>
<br />
<br />
</p>
</asp:Panel>
...
</form>
</html>
VB code:
-------
Imports ...

Public Class CustProfile
'For PostBack
Inherits Page

Protected txtAddNote as TextBox
Protected pnlAddNote as Panel
Protected WithEvents btnAddNote as Button
...

Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
btnAddNote.Click
txtAddNote.Text = ""
pnlAddNote.Visible = True
End Sub

...
End Class
And this is the error message I get which makes no sense to me because the
object is declared and exists in both files.

Browser Msg:
-----------

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles btnAddNote.Click
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visible = True
Line 426: End Sub

Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424

If anyone can shed some light on this subject (namely point out what I'm
doing wrong) it would be greatly appreciated.

A. Nonymous (slightly dazed and confused)

Nov 19 '05 #2
I figured out the problem:

txtAddNote.Text = "" (empty string) causes the problem

I alternatively used:

txtAddNote.Text = " " (a space)

....and all is well.

Sigh!

"A. Nonymous" <an*******@hotmail.com> wrote in message
news:2P********************@giganews.com...
Hello,

I am trying to set up a panel that appears on a page that prompts a user to enter in a note. This panel object is initially invisable and appears
when the user clicks on a button. Contained within the panel are a couple
of buttons and a textbox. Code is as follows:

ASPX page:
---------

<%@ Page Language="VB" Inherits="CustProfile" Src="CustProfile.vb"
autoeventwireup="False" %>
<html>
<form>
...

<td align="middle">
<asp:Button id="btnAddNote" runat="server" Text="Add New
Note"></asp:Button>
</td>
...

<asp:Panel id="pnlAddNote" style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; Z-INDEX: 1; BACKGROUND: silver; LEFT: 210px; BORDER-LEFT:
black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP:
265px" runat="server" Width="360px" Visible="False" HorizontalAlign="Left"> <p>
<strong>Add Note:</strong>
</p>
<p align="center">
<asp:TextBox id="txAddNote" runat="server" Columns="35"
AutoPostBack="True" Wrap="True" TextMode="MultiLine" Enabled="True"
Visible="True" Rows="4">Enter Note Here.</asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnSaveNote" runat="server" Text="Save Note" Enabled="True" Visible="True"></asp:Button>
&nbsp;
<asp:Button id="btnCancelNote" runat="server" Text="Cancel" Enabled="True" Visible="True"></asp:Button>
<br />
<br />
</p>
</asp:Panel>
...
</form>
</html>
VB code:
-------
Imports ...

Public Class CustProfile
'For PostBack
Inherits Page

Protected txtAddNote as TextBox
Protected pnlAddNote as Panel
Protected WithEvents btnAddNote as Button
...

Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles
btnAddNote.Click
txtAddNote.Text = ""
pnlAddNote.Visible = True
End Sub

...
End Class
And this is the error message I get which makes no sense to me because the
object is declared and exists in both files.

Browser Msg:
-----------

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Click(source as Object, e as EventArgs) Handles btnAddNote.Click
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visible = True
Line 426: End Sub

Source File: C:\Inetpub\wwwroot\incident\cust\CustProfile.vb Line: 424

If anyone can shed some light on this subject (namely point out what I'm
doing wrong) it would be greatly appreciated.

A. Nonymous (slightly dazed and confused)

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
0
by: Eric Diana | last post by:
I am trying to place an strings into an array of strings I am declaring as Dim Fields() As String I have another variable im doing the same thing with and it works. Public Shared Operations()...
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
2
by: Janet Heflin | last post by:
Very new in the C# world so give me a break here. I have created two web forms, one passes information to the other and brings up the data based on the passed field. When I do the updateRow I get...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
0
by: huobazi | last post by:
I have many dropdownlist controls in my ascx (and use LoadControl in a aspx fiel) file,so i write a method "InitList(DropDownList list,string strsql,string TextField,string ValueField)" but when i...
3
by: Patrick.O.Ige | last post by:
I'm loading an Array below but getting the error "Object reference not set to an instance saying 'ItemNumber = CType(Args.Item.FindControl("ItemNumber"), TextBox).Text' is the error line. I DON'T...
5
by: Patrick.O.Ige | last post by:
What could cause the error:- System.NullReferenceException: Object reference not set to an instance of an object. Any ideas?
5
by: ishanisircar | last post by:
hiya, i am using vb and asp.net with sql server. when the vb page is run, a gridview is displayed. In the gridview when a link button is clicked, a calendar is displayed. i am using this code to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.