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

Object reference not set to an instance of an object.?? Please Help

Hi,

I get the following error when trying to run a search on my aspx site,
this error only occours if the product im searching for does not
exist. Can anybody explain this please and help me with a solution, i
know its probably simple but im new to the game...Cheers

-----------------------------------------------------------------------

Object reference not set to an instance of an object.

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

Source Error:
Line 63: {
Line 64: strSearchValue = Request.QueryString["sv"];
Line 65: lblSearch.Text = "Your search for <b>'" +
strSearchValue + "'</b> brought back <b>no results</b>" ;
Line 66: }
Line 67:


Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
woodies.searchResults.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\woodies\searchresults.aspx.cs:6 5
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
-----------------------------------------------------------------
And here is the some of the code from the page which is prob relevant:
------------------------------------------------------------------

using System.Web.UI.WebControls;

..
..
..
public class searchResults : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblSearch;

..
..
..

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Request.ServerVariables["HTTPS"].ToString() !="off")
{siteImages = ConfigurationSettings.AppSettings["SiteImagesSecure"];}

if (Request.QueryString["sv"] != null && Request.QueryString
["sv"].ToString() != "")
{
strSearchValue = Request.QueryString["sv"];
lblSearch.Text = "Your search for <b>'" + strSearchValue + "'</b>
brought back <b>no results</b>" ;
}
Nov 16 '05 #1
4 2659
is your string strSearchValue anywhere instanced?

like:
string strSearchValue;

"

"Frawls" wrote:
Hi,

I get the following error when trying to run a search on my aspx site,
this error only occours if the product im searching for does not
exist. Can anybody explain this please and help me with a solution, i
know its probably simple but im new to the game...Cheers

-----------------------------------------------------------------------

Object reference not set to an instance of an object.

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

Source Error:
Line 63: {
Line 64: strSearchValue = Request.QueryString["sv"];
Line 65: lblSearch.Text = "Your search for <b>'" +
strSearchValue + "'</b> brought back <b>no results</b>" ;
Line 66: }
Line 67:


Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
woodies.searchResults.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\woodies\searchresults.aspx.cs:6 5
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
-----------------------------------------------------------------
And here is the some of the code from the page which is prob relevant:
------------------------------------------------------------------

using System.Web.UI.WebControls;

..
..
..
public class searchResults : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblSearch;

..
..
..

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Request.ServerVariables["HTTPS"].ToString() !="off")
{siteImages = ConfigurationSettings.AppSettings["SiteImagesSecure"];}

if (Request.QueryString["sv"] != null && Request.QueryString
["sv"].ToString() != "")
{
strSearchValue = Request.QueryString["sv"];
lblSearch.Text = "Your search for <b>'" + strSearchValue + "'</b>
brought back <b>no results</b>" ;
}

Nov 16 '05 #2
I hate to be picky, but have you actually stepped through your code in an
IDE and evaluated the variables being used? Unlike some other exceptions,
this one is pretty consistent and predictable. The error message itself is
not cryptic.

Step through your code and see what the value is for your variables at the
point where it fails. One of your variables has no value yet you are trying
to use it.
"Frawls" <fr****@gmail.com> wrote in message
news:32**************************@posting.google.c om...
Hi,

I get the following error when trying to run a search on my aspx site,
this error only occours if the product im searching for does not
exist. Can anybody explain this please and help me with a solution, i
know its probably simple but im new to the game...Cheers

-----------------------------------------------------------------------

Object reference not set to an instance of an object.

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

Source Error:
Line 63: {
Line 64: strSearchValue = Request.QueryString["sv"];
Line 65: lblSearch.Text = "Your search for <b>'" +
strSearchValue + "'</b> brought back <b>no results</b>" ;
Line 66: }
Line 67:


Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
woodies.searchResults.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\woodies\searchresults.aspx.cs:6 5
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
-----------------------------------------------------------------
And here is the some of the code from the page which is prob relevant:
------------------------------------------------------------------

using System.Web.UI.WebControls;

.
.
.
public class searchResults : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblSearch;

.
.
.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Request.ServerVariables["HTTPS"].ToString() !="off")
{siteImages = ConfigurationSettings.AppSettings["SiteImagesSecure"];}

if (Request.QueryString["sv"] != null && Request.QueryString
["sv"].ToString() != "")
{
strSearchValue = Request.QueryString["sv"];
lblSearch.Text = "Your search for <b>'" + strSearchValue + "'</b>
brought back <b>no results</b>" ;
}

Nov 16 '05 #3
Could it be that your lblSearch (I'm assuming a label control) has not yet
been instantiated? I'm not too familiar with ASP.NET, but is it possible
that the control is created after the Page_Load method is invoked and so you
need to wait until a later point in time to reference the control?

Tyler

"Frawls" <fr****@gmail.com> wrote in message
news:32**************************@posting.google.c om...
Hi,

I get the following error when trying to run a search on my aspx site,
this error only occours if the product im searching for does not
exist. Can anybody explain this please and help me with a solution, i
know its probably simple but im new to the game...Cheers

-----------------------------------------------------------------------

Object reference not set to an instance of an object.

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

Source Error:
Line 63: {
Line 64: strSearchValue = Request.QueryString["sv"];
Line 65: lblSearch.Text = "Your search for <b>'" +
strSearchValue + "'</b> brought back <b>no results</b>" ;
Line 66: }
Line 67:


Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
woodies.searchResults.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\woodies\searchresults.aspx.cs:6 5
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
-----------------------------------------------------------------
And here is the some of the code from the page which is prob relevant:
------------------------------------------------------------------

using System.Web.UI.WebControls;

.
.
.
public class searchResults : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblSearch;

.
.
.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Request.ServerVariables["HTTPS"].ToString() !="off")
{siteImages = ConfigurationSettings.AppSettings["SiteImagesSecure"];}

if (Request.QueryString["sv"] != null && Request.QueryString
["sv"].ToString() != "")
{
strSearchValue = Request.QueryString["sv"];
lblSearch.Text = "Your search for <b>'" + strSearchValue + "'</b>
brought back <b>no results</b>" ;
}

Nov 16 '05 #4
Thanks for the advice guys, much appreciated. The problem was that i
did not have an ASP:label with an ID= lblSearch in my search
Results.aspx page. I no longer recieve the error message, however the
page now seems to try to load and reload infinately without displaying
any information.... So more work for me....

Thanks again,
frawls

Nov 16 '05 #5

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

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
3
by: nemo | last post by:
Hi, My application works fine on the localhost but spits this error as soon as I put it on the server. I know this error occurs when an object has not been instantiated prior to a reference, but...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
3
by: Brano | last post by:
HI all, I have a problem i have a web application that was working fine and this morning when i run it and click on a button that does Reponse.Redirect to a page i get this error : Server...
2
by: Hennie | last post by:
I Get the following error all of a sudden: I do not know what is wrong or where to start looking. I added the Debug="true" directive at the top of the page, but it does not help at all. What...
1
by: Nathan Sokalski | last post by:
I have a UserControl that I declare programmatically as follows: Dim userctrl as New rightside_portal() The codebehind file for this UserControl looks like the following: Partial Public...
23
by: Hugh Oxford | last post by:
How do I get an object's name? EG. $obj_FOO = new Bar; echo $obj_FOO->getName(); 'obj_FOO'
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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: 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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.