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>" ;
}