473,662 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.NullRefe renceException 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="CustP rofile" Src="CustProfil e.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="T rue" Wrap="True" TextMode="Multi Line" 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="btnCancelNo te" 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_Clic k(source as Object, e as EventArgs) Handles
btnAddNote.Clic k
txtAddNote.Text = ""
pnlAddNote.Visi ble = 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.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Clic k(source as Object, e as EventArgs)
Handles btnAddNote.Clic k
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visi ble = True
Line 426: End Sub

Source File: C:\Inetpub\wwwr oot\incident\cu st\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 2442
Please disregard this post.

I think I've found a way using JavaScript.
"A. Nonymous" <an*******@hotm ail.com> wrote in message
news:2P******** ************@gi ganews.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="CustP rofile" Src="CustProfil e.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="T rue" Wrap="True" TextMode="Multi Line" 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="btnCancelNo te" 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_Clic k(source as Object, e as EventArgs) Handles
btnAddNote.Clic k
txtAddNote.Text = ""
pnlAddNote.Visi ble = 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.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Clic k(source as Object, e as EventArgs) Handles btnAddNote.Clic k
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visi ble = True
Line 426: End Sub

Source File: C:\Inetpub\wwwr oot\incident\cu st\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*******@hotm ail.com> wrote in message
news:2P******** ************@gi ganews.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="CustP rofile" Src="CustProfil e.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="T rue" Wrap="True" TextMode="Multi Line" 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="btnCancelNo te" 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_Clic k(source as Object, e as EventArgs) Handles
btnAddNote.Clic k
txtAddNote.Text = ""
pnlAddNote.Visi ble = 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.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:

Line 422:
Line 423: Private Sub btnAddNote_Clic k(source as Object, e as EventArgs) Handles btnAddNote.Clic k
Line 424: txtAddNote.Text = ""
Line 425: pnlAddNote.Visi ble = True
Line 426: End Sub

Source File: C:\Inetpub\wwwr oot\incident\cu st\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
9130
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 system.windows.forms.dll
0
2241
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() As String This is the error I am getting
0
9771
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" AutoPostBackOnNodeMove="false" DragAndDropEnabled="true" NodeEditingEnabled="False" KeyboardEnabled="true" CssClass="TreeView" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode" HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit"
2
7646
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 the object recrence not set to an instance of an object. If I rem out the error message on the update it goes through and acts as though it updates but does not. Here is the updateRow statements: private void updateRow(object source,...
2
7806
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 in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
0
1974
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 want to get the BigClassList.SelectedItem.Text and BigClassList.SelectedItem.Value in a button onclick method,btnSmallClassEdit_Click(....),there post an error " System.NullReferenceException: 佫¶ÔÏóÒýÓÃÉèÖõ½¶ÔÏóµÄʵÀý¡£", I Don't know the...
3
4142
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 KNOW WHAT I'M DOING WRONG I USED ASP.NETWebMatrix and its working well!! Any help!! I have declared ItemNumber as u can see below " :-
5
1582
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
2362
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 displat the calendar. but i keep getting a System.NullReferenceException. how can i remove this? i get an error on this line of my code CType(grTemp.FindControl("txtRenewTill"), TextBox).Visible = True here is my code:
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8546
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.