Set Search Criteria in Codebehind RRS feed

  • Question

  • User1988740161 posted

     Hi,  I'm looking for a way to set up pages where the search criteria is preset in the code behind file, so the user just clicks a button or a link and goes to a page listing the appropriate ads.

    For example a page ONLY for category A ads, a page ONLY for a specific location, city or price range.  I want the user to just click the button or link and the correct dynamic page to appear without the use entering any text box or dropdownlist selections.  I'd appreciate any suggestions or hints if someone has already done something along this line.  Thanks.

    Monday, July 27, 2009 1:23 AM

All replies

  • User1403672759 posted

    I may be mistaken, but it sounds like you just need a regular hyperlink to send the user to specific pages...


    <a href="www.searchThisSite.com?searchCrit=Apples">Food</a>

    Monday, July 27, 2009 3:58 AM
  • User1988740161 posted

     Well, I have two pages which do searching...Search.aspx and AdvancedSearch.aspx, both from the original starterkit.  Both require the user to enter search criteria via dropdownlist or text boxes.  I want to create a page where the user clicks and only ads where the location is California show up in a list like Search.aspx, and another page where the user clicks and only ads where the location is Arizona show up, etc.

    The pages would be created dynamically based on search criteria specified in the vb file.  So when search in California.aspx is clicked would return ads in California based on criteria in California.aspx.vb.  Is there a way to do this?  Thanks.

    Monday, July 27, 2009 10:23 AM
  • User1403672759 posted

    You would need some kind of data file storing a location property of these ads.  Then it would be relatively easy to grab the ads from the data file based upon the criteria the user enters.  Where are you retrieving/storing these ads? 

    Tuesday, July 28, 2009 12:53 PM
  • User1988740161 posted

     The ads are in a sqlserver database.  I'm using the database that comes with the classified starterkit.  I have working searches which rely on the user to enter location in a textbox via dropdown list.  I want to set the location search criteria so when the user goes to the page, the ads are displayed without the user selecting any location.  So, when you go to the California page, all the california ads are displayed.  Thanks

    Tuesday, July 28, 2009 4:06 PM
  • User1403672759 posted

    I'm going to assume you have retrieved the users location some other way through your application.  All you need to do is either pass what state you want to show up in either a query string or hide it in a label and post the form to your search page.  Then grab all the items from your database associated to that State.

    Am I missing something or is this what you are trying to accomplish?

    Tuesday, July 28, 2009 4:26 PM
  • User1988740161 posted

     Hi.  I think you've got it right.  Maybe the thing I didn't mention is that I'm just a beginner working with a starterkit and most of what you said in your reply, I don't really understand how to do.

    I've been using the forums and making adjustments around the edges to the classified starter kit, but haven't found any postings telling how to do this thing.  I've tried various methods, trying to copy searches which came with the starterkit, but haven't been able to make any of them work yet.  Thanks


    Tuesday, July 28, 2009 7:23 PM
  • User1403672759 posted

    Yeah,  I've never used a starter kit.  I'm sure they're great for beginners, but as soon as you need to change something it can be a bit tricky.  If you still need help with this issue feel free to post some of the code you have, and I'll be more than happy to help.

    Wednesday, July 29, 2009 8:25 AM
  • User1988740161 posted


    Thought I'd try a different approach. I copied the commonwhatsnewrangelist from the default page and tried to use it on another page to select a single location.   I need the selection to carry over to the advanced search page (I think).   I don't understand the error.   Any suggestions?  I'm really stuck.


    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

    Source Error:

    Line 7:      Inherits System.Web.UI.Page
    Line 8:  
    Line 9:      Protected Sub AircraftForSaleCalifornia_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AircraftForSaleCalifornia.Click
    Line 10: 
    Line 11:         AircraftForSaleCaliforniaButton.CommandArgument = "CrossPagePost"

    Source File: d:\hosting\rporterpg\AdvancedSearch.aspx.vb    Line: 9

    Show Detailed Compiler Output:

    c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\\System.Web.Mobile.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\assembly\dl3\75942117\99090c95_c5b5c901\UrlRewritingNet.UrlRewriter.DLL" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_advancedsearch.ascx.cc671b29.jny1r7us.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\\System.Web.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_global.asax.x8qh8jxy.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\\System.Drawing.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Code.esvk2dqj.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\\System.Configuration.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_ot4w_rex.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\\System.ServiceModel.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_z7hsaqr2.dll" /D:DEBUG=1 /debug+ /win32resource:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\z7hsaqr2.res" /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls  "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_z7hsaqr2.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_z7hsaqr2.1.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\74a96ed8\43b09a3c\App_Web_z7hsaqr2.2.vb"
    Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
    for Microsoft (R) .NET Framework version 2.0.50727.3053
    Copyright (c) Microsoft Corporation.  All rights reserved.
    http://server/AdvancedSearch.aspx.vb(9) : error BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
        Protected Sub AircraftForSaleCalifornia_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AircraftForSaleCalifornia.Click
    http://server/AdvancedSearch.aspx.vb(11) : error BC30451: Name 'AircraftForSaleCaliforniaButton' is not declared.
            AircraftForSaleCaliforniaButton.CommandArgument = "CrossPagePost"

    Show Complete Compilation Source:

    Tuesday, August 4, 2009 4:54 PM
  • User1403672759 posted

    It's looking for a button/linkbutton called "AircraftForSaleCalifornia".  Do you have an element on your aspx page with this as it's ID? 

    Wednesday, August 12, 2009 12:33 PM
  • User-578273483 posted


    I have introduced IP adress location plus a zone criteria filter (try to find classifieds 500 km around Paris, France)


    I hope my message can give you an idea of what you could implement to benefit from  geographical criteria



    Thursday, August 20, 2009 9:00 AM