Problems with Advanced Search

Last post 10-21-2009 12:49 PM by flipknob. 8 replies.

Sort Posts:

  • Problems with Advanced Search

    07-10-2007, 12:35 AM
    • Contributor
      3,429 point Contributor
    • rfurdzik
    • Member since 07-01-2002, 6:32 PM
    • zikbay.com
    • Posts 1,721

    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?

  • Re: Problems with Advanced Search

    07-10-2007, 11:43 AM
    • Contributor
      2,576 point Contributor
    • darkknight187
    • Member since 09-14-2006, 4:35 AM
    • Bothell, Washington
    • Posts 1,009

    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.

     

     

    Please remember to click “Mark as Answer” on the post that helps you.
    This can be beneficial to other community members reading the thread.
  • Re: Problems with Advanced Search

    07-11-2007, 7:18 PM
    • Contributor
      3,429 point Contributor
    • rfurdzik
    • Member since 07-01-2002, 6:32 PM
    • zikbay.com
    • Posts 1,721

    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?

  • Re: Problems with Advanced Search

    07-11-2007, 9:38 PM
    • Contributor
      2,576 point Contributor
    • darkknight187
    • Member since 09-14-2006, 4:35 AM
    • Bothell, Washington
    • Posts 1,009

    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

    And I'm not familiar with C#.

    Good Luck 

    Please remember to click “Mark as Answer” on the post that helps you.
    This can be beneficial to other community members reading the thread.
  • Re: Problems with Advanced Search

    07-11-2007, 9:40 PM
    • Contributor
      3,429 point Contributor
    • rfurdzik
    • Member since 07-01-2002, 6:32 PM
    • zikbay.com
    • Posts 1,721

     

    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

     

     

  • Re: Problems with Advanced Search

    07-11-2007, 9:47 PM
    • Contributor
      3,429 point Contributor
    • rfurdzik
    • Member since 07-01-2002, 6:32 PM
    • zikbay.com
    • Posts 1,721

     

    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?
  • Re: Problems with Advanced Search

    07-11-2007, 10:09 PM
    • Contributor
      3,429 point Contributor
    • rfurdzik
    • Member since 07-01-2002, 6:32 PM
    • zikbay.com
    • Posts 1,721

     

    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...
  • Re: Problems with Advanced Search

    05-15-2009, 11:32 AM
    • Member
      20 point Member
    • flipknob
    • Member since 09-03-2008, 2:39 PM
    • Posts 71

     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.

    flip
  • Re: Problems with Advanced Search

    10-21-2009, 12:49 PM
    • Member
      20 point Member
    • flipknob
    • Member since 09-03-2008, 2:39 PM
    • Posts 71

    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.

    flip
Page 1 of 1 (9 items)