locked
Problems with Advanced Search RRS feed

  • Question

  • User-1329334484 posted

    I have extended Advanced Search with the following: Country, City, State.

    When I click search, GetAllAdsByQuery is executed fine, however after that a second postback is generated and GetAllAdsByQuery is executed with empty parameters...

    Any idea why this second postback to advanced search occurs? Why GetAllAdsByQuery is called twice?

    Tuesday, July 10, 2007 12:35 AM

All replies

  • User730446648 posted

    It sounds like, when it is doing a postback on your Search Results page, it is clearing the advanced search. That's where I would start with it.

    Go through your code behind on the Search page. Maybe you used the clear search onclick event.

     

     

    Tuesday, July 10, 2007 11:43 AM
  • User-1329334484 posted

    I ahve added this code to the Load event of the LocationDropdown control:

    if (!Page.IsPostBack)

    {

    ddlCountry.Items.Insert(0,
    String.Empty);ddlState.Items.Insert(0, String.Empty);

    Reset();

    ToggleStateDrop(
    false);

    }

     

    The problem is that this code is executed again (second postback) and it overwrites what user has selected already... Any idea?

    Wednesday, July 11, 2007 7:18 PM
  • User730446648 posted

    Sorry no ideas, but I did notice you are getting an error every once in a while.

    Server Error in '/' Application.

    A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

    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.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

    Source Error:

    Line 1878:            this.Adapter.SelectCommand.Parameters[3].Value = ((int)(AdLevel));
    Line 1879:            AdsDataComponent.AdsDataTable dataTable = new AdsDataComponent.AdsDataTable();
    Line 1880:            this.Adapter.Fill(dataTable);
    Line 1881:            return dataTable;
    Line 1882:        }

    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\adcedb30\296393a\App_Code.bmic_npf.25.cs    Line: 1880

    <!-- [SqlException]: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParserStateObject.WriteSni() at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode) at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush() at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at AdsDataComponentTableAdapters.AdsDataAdapter.GetAdsByRandomOrder(Int32 NumRecords, Int32 AdStatus, Int32 AdLevel) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\adcedb30\296393a\App_Code.bmic_npf.25.cs:line 1880 at AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB.GetFeaturedAdsSelection(Int32 maxNumAds) in d:\ultimaweb\rafal\zikbay.com\wwwroot\App_Code\BLL\Ads.cs:line 241 at AspNet.StarterKits.Classifieds.Web.FeaturedAdCache.FetchFeaturedAd() in d:\ultimaweb\rafal\zikbay.com\wwwroot\App_Code\Web\FeatureCache.cs:line 90 at AspNet.StarterKits.Classifieds.Web.FeaturedAdCache.GetFeaturedAd(HttpContext context) in d:\ultimaweb\rafal\zikbay.com\wwwroot\App_Code\Web\FeatureCache.cs:line 74 at AspNet.StarterKits.Classifieds.Web.FeaturedAdCache.GetFeaturedAd() in d:\ultimaweb\rafal\zikbay.com\wwwroot\App_Code\Web\FeatureCache.cs:line 59 [TargetInvocationException]: Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) at System.Web.UI.WebControls.Repeater.GetData() at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.Repeater.DataBind() at System.Web.UI.WebControls.Repeater.EnsureDataBound() at System.Web.UI.WebControls.Repeater.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP._default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\adcedb30\296393a\App_Web_pakhkhwa.2.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->

    And I'm not familiar with C#.

    Good Luck 

    Wednesday, July 11, 2007 9:38 PM
  • User-1329334484 posted

     

    The problem is that there is hidden Advanced Search Control on search.aspx. Here is what I think is happening:

    1) In my code somwhere in Search.aspx.cs another postback is generated back to Search.aspx.

    2)  Loading all controls happens again, including advanced_search hiden control

    3) When advanced_search control loads, it resets itself, because of the initialization code I have placed there

    4) Once it resets itself, city, state and country is empty again

     

    What would be the best way to fight this scenario? I was thinking maybe if I can place the advanced_search control to viewstate, that would work? I could check if viewstate is null, if not just retrieve the control from viewstate... I am not sure how to do it and if this is a good idea at all...

     Please help

     

     

    Wednesday, July 11, 2007 9:40 PM
  • User-1329334484 posted

     

    As far as the TCP error, my hosting provider have told me there is a problem with the code. They only allow 10 concurent connections to the SQL Server. They said that connections are not properly closed in CSK code? Any idea?
    Wednesday, July 11, 2007 9:47 PM
  • User-1329334484 posted

     

    Just want you to know that I have fixed the problem with reseting of the city. I have removed initialization code from load and I have enabled viewstate on all controls in advanced search. I have also added "" as the first option in the lists...
    Wednesday, July 11, 2007 10:09 PM
  • User201849722 posted

     Greetings,

     I know you've already fixed this and have probably been using it with good results for a while but I have another solution in case anyone else happens accross this.

    I've had this very same issue happen multiple times on the search page as well as the ad posting page. What I did to clear up the problem was to copy all the custom code I had written into a seperate text document (just so I didn't have to rewrite the code). Then I get a copy of the original pages code behind and overwrite your modified page entirely. Then I add back in my custom code and it works as it should with a single pass through the code behind.

    Why this is happening, I can't even begin to explain. But my solution fixes the issue with my project. It wasn't anything with my code that messed it up.

    Hope this helps someone.

    Friday, May 15, 2009 11:32 AM
  • User201849722 posted

    Dead thread, I know, but here is the solution to the whole problem.

    The search button has an OnClick attribute that it is running when you search for something. In the code behind for the search button remove "Handles SearchButton.Click" from the Protected Sub.

    Both of those are telling the search to happen so you get a double search out of it.

    This sometimes happens when posting an ad as well.

    Again, in case someone happens accross this post with the same issue.

    Wednesday, October 21, 2009 12:49 PM