1. Starting with search.aspx I have added to the object database;
<
asp:ControlParameter
Name="TextBox1"
DefaultValue=""
Type="String"
ControlID="TextBox1"
PropertyName="Text"></asp:ControlParameter>
2. With regards to App_Code/BLL/Ads.vb (GetAds section)
Public
Shared
Function GetActiveAdsByQuery(ByVal recordLimit
As
Integer,
ByVal categoryId
As
Integer,
ByVal memberId
As
Integer,
ByVal maxPrice
As
Decimal,
ByVal searchTerm
As
String,
ByVal TextBox1
As
String,
ByVal location
As
String,
ByVal adType
As
Integer,
ByVal adLevel
As
Integer,
ByVal dayRange
As
Integer,
ByVal mustHaveImage
As
Boolean)
As AdsDataComponent.AdsDataTable
Grateful if you could quality check me before next steps!
Okay this is what I have done so far - could you check for me please, seems ok?
I am not sure next steps to specify data that textbox1 is pulling from, I have now uploaded to
www.localstar.com.au if you want to see, very grateful.
1. GetActiveAdsByQuery
Public Shared
Function GetActiveAdsByQuery(ByVal recordLimit
As Integer,
ByVal categoryId
As Integer,
ByVal memberId
As Integer,
ByVal maxPrice
As Decimal,
ByVal searchTerm
As String,
ByVal TextBox1
As String,
ByVal location
As String,
ByVal adType As
Integer, ByVal adLevel
As Integer,
ByVal dayRange
As Integer,
ByVal mustHaveImage
As Boolean)
As AdsDataComponent.AdsDataTable
Dim escapedSearchTerm
As String = AdsDB.EscapeWildcardCharacters(searchTerm)
Dim escapedtextbox1
As String = AdsDB.EscapeWildcardCharacters(TextBox1)
Dim escapedLocation
As String = AdsDB.EscapeWildcardCharacters(location)
Return GetAdsByQuery(recordLimit, _
categoryId, memberId, maxPrice, _
HttpUtility.HtmlEncode(escapedSearchTerm), _
HttpUtility.HtmlEncode(escapedtextbox1), _
HttpUtility.HtmlEncode(escapedLocation), _
adType, CInt(AdStatus.Activated), _
adLevel, dayRange, mustHaveImage)
End Function
2.
GetAdsByQuery
Public
Shared Function GetAdsByQuery(ByVal recordLimit
As Integer,
ByVal categoryId
As Integer,
ByVal memberId
As Integer,
ByVal maxPrice
As Decimal,
ByVal searchTerm
As String,
ByVal textbox1
As String,
ByVal location
As String,
ByVal adType As
Integer, ByVal adStatus
As Integer,
ByVal adLevel
As Integer,
ByVal dayRange
As Integer,
ByVal mustHaveImage
As Boolean)
As AdsDataComponent.AdsDataTable
Dim minCreatedDate
As System.Nullable(Of DateTime)
If location
Is Nothing
Then
roymartian
Member
54 Points
151 Posts
How to add another searchtextbox ?
Feb 21, 2008 10:34 AM|LINK
I am trying to add another search text box that references another data field.
I can successfully use the existing commonsearchtextbox to search title data but do not know how to add another search box.
I have created a new search box in default.aspx, (www.localstar.com.au)<
asp:TextBox ID="TextBox1" Runat="server" CssClass="search_box" AccessKey="s" TabIndex="1"></asp:TextBox>However I am not sure what other modifications or additions are required, I can see details in;
default.aspx.vb
search.aspx.vb
admin/default.aspx
admin/ads.aspx.vb
search.aspx
and also, storedprocedure GetAllAdsByQuerry
Could anyone please advise me on a simple method to create the second search box - it would be great.
My objective is to be able to search by business & postcode / area (fields to be added to database).
You can see my attempt at www.localstar.com.au
Thanks,
Roy.
darkknight18...
Contributor
2674 Points
1040 Posts
Re: How to add another searchtextbox ?
Feb 22, 2008 02:40 AM|LINK
I'm not sure how to setup one search textbox that will return results from two columns, but it should be a small modification.
Basically to add another search function you have to modify several files, Save a backup first.
The files are, StoredProcedure, GetAllAdsByQuery,
Ads.xsd for get all ads. (I like to use view code for a more specific modification.)
Ads.vb in the get ads section
And the Searchpage itself
If you get stuck show me your code, and I'll help you.
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
roymartian
Member
54 Points
151 Posts
Re: How to add another searchtextbox ?
Feb 24, 2008 10:12 AM|LINK
Thanks for the guidance.
Okay, this is what I've been trying - most weekend, can you help me confirm the code;
1. StoredProcedure/GetAllAdsQuery
I have added, (Must declare Scalar variable ???)Title
LIKE '%' + @Textbox1 + '%' AND2. Ads.xsd
I tried copying the existing code below using textbox1 instead of "@SearchTerm"
<
Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="@SearchTerm" Precision="0" ProviderType="NVarChar" Scale="0" Size="50" SourceColumnNullMapping="False" SourceVersion="Current">3. Default.aspx
<
asp:TextBox ID="TextBox1" Runat="server" CssClass="search_box" AccessKey="s" TabIndex="1"></asp:TextBox>4. Search.aspx.vb
' carry over just search term as regular search in categorySearchTermTextBox.Text = advParameters.SearchTerm
TextBox1.Text = advParameters.SearchTerm
This seems pretty tricky especially search.aspx.vb as searchtermtext is threaded right through the page!
Would be v.cool if can incorporate two search boxes.
Grateful if you could advise me.
Roy.
darkknight18...
Contributor
2674 Points
1040 Posts
Re: How to add another searchtextbox ?
Feb 24, 2008 02:54 PM|LINK
Don't focus too much on the carrry over right now, just get it working from the primary search page.
You are missing two entries though.
1. at the bottom of your search page you need to add to the object database.
2. it looks like you didn't add anything to the App_Code/BLL/Ads.vb (GetAds section)
After it works, then work on the carry over.
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
roymartian
Member
54 Points
151 Posts
Re: How to add another searchtextbox ?
Feb 25, 2008 10:06 AM|LINK
Okay step by step,
1. Starting with search.aspx I have added to the object database;
<
asp:ControlParameter Name="TextBox1" DefaultValue="" Type="String" ControlID="TextBox1" PropertyName="Text"></asp:ControlParameter> 2. With regards to App_Code/BLL/Ads.vb (GetAds section)Public
Shared Function GetActiveAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal TextBox1 As String, ByVal location As String, ByVal adType As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTableGrateful if you could quality check me before next steps!
R.
darkknight18...
Contributor
2674 Points
1040 Posts
Re: How to add another searchtextbox ?
Feb 25, 2008 04:54 PM|LINK
In BLL/Ads.vb there is two sections that need to be modified
1. GetActiveAdsByQuery
you do the ByVal like you did above, that part's good.
right after that you need to add to the return textbox1
2. GetAdsByQuery
Same as above, Add to the ByVal, and add to theDim
aa As AdsDataComponent.AdsDataTable = Nothingaa = . . . . . . .
Then the search should work with your new box
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
roymartian
Member
54 Points
151 Posts
Re: How to add another searchtextbox ?
Feb 26, 2008 09:38 AM|LINK
Okay this is what I have done so far - could you check for me please, seems ok?
I am not sure next steps to specify data that textbox1 is pulling from, I have now uploaded to www.localstar.com.au if you want to see, very grateful.
1. GetActiveAdsByQuery
Public Shared Function GetActiveAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal TextBox1 As String, ByVal location As String, ByVal adType As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable Dim escapedSearchTerm As String = AdsDB.EscapeWildcardCharacters(searchTerm) Dim escapedtextbox1 As String = AdsDB.EscapeWildcardCharacters(TextBox1) Dim escapedLocation As String = AdsDB.EscapeWildcardCharacters(location) Return GetAdsByQuery(recordLimit, _categoryId, memberId, maxPrice, _
HttpUtility.HtmlEncode(escapedSearchTerm), _
HttpUtility.HtmlEncode(escapedtextbox1), _
HttpUtility.HtmlEncode(escapedLocation), _
adType, CInt(AdStatus.Activated), _adLevel, dayRange, mustHaveImage)
End Function2. GetAdsByQuery
Public Shared Function GetAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal textbox1 As String, ByVal location As String, ByVal adType As Integer, ByVal adStatus As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable Dim minCreatedDate As System.Nullable(Of DateTime) If location Is Nothing Thenlocation =
"" End If If dayRange > 0 ThenminCreatedDate = DateTime.Now.Subtract(TimeSpan.FromDays(dayRange))
End If ' To return no results if the searchTerm is empty remove the following ' check on the searchTerm. If searchTerm Is Nothing ThensearchTerm =
"" End If Using db As New AdsDataAdapter() Dim aa As AdsDataComponent.AdsDataTable = Nothingaa = db.GetAllAdsByQuery(recordLimit, categoryId, memberId, maxPrice, textbox1, location, adType, adStatus, adLevel, minCreatedDate, mustHaveImage)
Return aa End Using End FunctionBig Thanks,
R.
darkknight18...
Contributor
2674 Points
1040 Posts
Re: How to add another searchtextbox ?
Feb 26, 2008 06:56 PM|LINK
Where's searchterm??
Other than that it looks good.
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
roymartian
Member
54 Points
151 Posts
Re: How to add another searchtextbox ?
Feb 26, 2008 08:16 PM|LINK
My mistake, I have inadvertently removed - I will fix tonight.
However new search box "textbox1" does not provide any results, how do I now specify data field its calling upon, don't think I have set this yet?
Was this the Ads.xsd page modifications?
Could you advise whats left to modify to make his fully functional on the search page.
Thanks,
R.
darkknight18...
Contributor
2674 Points
1040 Posts
Re: How to add another searchtextbox ?
Feb 26, 2008 08:26 PM|LINK
Which column is set from the storedprocedure, and you currently have it set for title.
Title LIKE '%' + @Textbox1 + '%' AND
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.