HKFuey
asked on
Back Slashes break search aspx.cs
If a user searches our web site for a product with more than one slash e.g. 123/456/1
They get this error: -
Server Error in '/' Application.
Content controls are allowed only in content page that references a master page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Content controls are allowed only in content page that references a master page.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Content controls are allowed only in content page that references a master page.]
System.Web.UI.MasterPage.C reateMaste r(Template Control owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8672243
System.Web.UI.Page.get_Mas ter() +51
System.Web.UI.Page.ApplyMa sterPage() +15
System.Web.UI.Page.Perform PreInit() +45
System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt) +282
I have inserted the code that I think does the search, please be patient as I'm not familiar with this stuff.
They get this error: -
Server Error in '/' Application.
Content controls are allowed only in content page that references a master page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Content controls are allowed only in content page that references a master page.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Content controls are allowed only in content page that references a master page.]
System.Web.UI.MasterPage.C
System.Web.UI.Page.get_Mas
System.Web.UI.Page.ApplyMa
System.Web.UI.Page.Perform
System.Web.UI.Page.Process
I have inserted the code that I think does the search, please be patient as I'm not familiar with this stuff.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class SearchResults : Wombat.Business.Page
{
protected override void OnPreInit(EventArgs e)
{
WombatMasterPage = "content.master";
base.OnPreInit(e);
}
protected string SearchText
{
get
{
if (ViewState["SearchText"] == null)
return "";
else
return (string)ViewState["SearchText"];
}
set
{
ViewState["SearchText"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
((HtmlHead)this.Master.FindControl("oHead")).Title = "CompanyName - Search";
if (!IsPostBack)
{
if (Request.QueryString["SearchText"] != null)
{
SearchText = Request.QueryString["SearchText"].ToString();
if(SearchText!=string.Empty)
Search();
}
}
}
private void Search()
{
DataTable dtbSearchResults = Business.Search.SearchCompanyName(SearchText);
repSearchResults.DataSource = dtbSearchResults;
repSearchResults.DataBind();
if (repSearchResults.Items.Count == 0)
repSearchResults.Visible = false;
else
repSearchResults.Visible = true;
lbResults.Text = "You searched for <span style=\"color:red;\">" + SearchText + "</span> and it returned " + repSearchResults.Items.Count.ToString() + " results";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER