473,395 Members | 1,411 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,395 software developers and data experts.

NullReference Exception - Why?

I keep getting the following error with the code below:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Caused by this line:

this.basicSearch.OnSomethingHappened += new
System.EventHandler(this.ShowResult);
Here is some of my code:

CODE
private void ShowResult(object sender, System.EventArgs e)
{
this.results.searchData = ((BasicSearch)sender).searchData;
PlaceHolder1.Controls.Clear();
resultsCtrl = LoadControl("results.asxc");
PlaceHolder1.Controls.Add(resultsCtrl);
Response.Write("NOT HAPPENING");
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.basicSearch.OnSomethingHappened += new
System.EventHandler(this.ShowResult);

}
OnSomethingHappenened is an event declared in my BasicSearch usercontrol page.

Any ideas whats wrong?
Regards,

Wallace
Jul 21 '05 #1
2 1358
Wallaceoc,

Although in this newsgroup are persons active who know a lot of C# is the
better place for C# related questions

microsoft.public.dotnet.languages.csharp

Cor
Jul 21 '05 #2
wallaceoc <wa*******@discussions.microsoft.com> wrote:
I keep getting the following error with the code below: Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Caused by this line:

this.basicSearch.OnSomethingHappened += new
System.EventHandler(this.ShowResult);


That suggests that basicSearch is null. What have you done to make sure
it's not null?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

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

Similar topics

2
by: Larry Re | last post by:
I've written a small C# app which appears to work perfectly except for the fact that I get a NullReference exception when I close the form using the red 'X' in the upper right hand corner of the...
3
by: Tom | last post by:
Hi, I built a class project (classproject.dll) and a web project (webproject.dll). The web project needs to reference to that class project. They can compile without error. But, it has...
5
by: Paul Cheetham | last post by:
Hi, I have moved a fairly large project from VS2003 to VS2005, and now trying to get it running. It now compiles OK after minimal changes, but I am now getting a NullReference Exception on...
0
by: Raymondr | last post by:
Hi, First a brief description of out application: We have a webapplication which calls a couple of webservices during one request (postback). These calls to the webservices are made concurrent...
0
by: studio60podcast | last post by:
I'm defining the ItemUpdating event for a DetailsView control, but when I try to access the e.NewValues collection, it's throwing a NULLReference exception. Any thoughts? <asp:DetailsView...
1
by: Rama Jayapal | last post by:
i have written the following code to call a method in a class like in the aspx.cs page List<string> surls = new List<string>(); Cweb.GetMainUrls(document,ref surls); Response.Write(surls); ...
4
by: yogarajan | last post by:
hi i had developed pop3 Account mail view in my web page but i got error in (System.NullReference Exception: Object reference not set) NetStrm.Write(szData, 0, szData.Length); - this line ...
0
by: =?Utf-8?B?RGlzcEV2ZW50QWR2aXNlIGZhaWxzIHdpdGggMHg4 | last post by:
Hi, I have a beginner's question and I'm not even sure whether it's an asp question, an Exchange server question or an x64 question... I've been experimenting with HttpModules. I want to use one in...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.