Reply
Custom Site Search - NOT GOOGLE
Old 06-26-2009, 09:50 AM Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
I want to add a site search to my company's web site. We don't want to pay for Google's professional search box, nor do we want the advertisements from the free one.

Does anyone know how to go about getting started? I realize that I'm going to have to create a database, with keywords, links and other text... but is there a way around that? Perhaps XML?

I'm just trying to gather ideas before getting started... If anyone knows how to get started, please let me know...
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
 
When You Register, These Ads Go Away!
Old 06-26-2009, 05:59 PM Re: Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
Ok, so - I think I might have a solution, but I need your help.

If I have a text box and button setup, is it possible to use an asp:repeater control to display the search results?

If so, how would I go about populating it from the text box using a stored procedure in my sql data source?

(Keep in mind that I don't know C#.)

This is how I was thinking I would do it - so far.... please let me know if you think it's a bad idea.... or more complicated than what I'm thinking... as I'm sure someone will.

Code:
<asp:RepeaterID="rpt1"runat="server"DataSourceID="SqlDataSource1">
<HeaderTemplate>
<ahref="<%# DataBinder.Eval(Container.DataItem, "headers") %>"style="color:#9e6917;">
<%# DataBinder.Eval(Container.DataItem, "Name") %></a><br/>
</HeaderTemplate>
<ItemTemplate>
<ahref="<%# DataBinder.Eval(Container.DataItem, "descriptions") %>"style="color:#000000;">
<%# DataBinder.Eval(Container.DataItem, "Name") %></a><br/>
</ItemTemplate>
<FooterTemplate>
<ahref="<%# DataBinder.Eval(Container.DataItem, "urls") %>"style="color:#00508e;">
<%# DataBinder.Eval(Container.DataItem, "Name") %></a><br/>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:StringName %>"SelectCommand="storedprocedurename"SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameterFormField="txtSearchBar"Name="keyword"Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
From there, I need to get the code to bind the data for when the user clicks the "search button":
Code:

ProtectedSub btnSearch_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnSearch.Click
Any ideas?
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-29-2009, 01:58 PM Re: Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
Ok, so my solution for the Custom Site Search wasn't that hard...

This is how I did it: (I know--- I used tables... shame on me...)
Code:
<form id="frmSearch" method="post" action="Search.aspx" runat="server">
<table align="center" width="800px">
<tr>
<td style="margin:25px;padding:25px;width:750px; height: 69px;">
<table>
<tr>
<td style="width:250px; height: 63px; text-align: center;">
<asp:Image ID="Image1" runat="server" ImageUrl="image/mslogo.gif"/>
</td>
<td style="width:250px; height: 63px;">
<asp:TextBox ID="txtSearchBar" runat="server" Width="290px" BorderColor="Blue" BorderStyle="Ridge"></asp:TextBox>
</td>
<td style="width:250px; height: 63px; text-align: center;">
<asp:Button ID="btnSearch" runat="server" Text="Search" Width="88px"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="margin:5px;padding:5px;width:750px;height:550px; text-align: left;">
<asp:Repeater ID="rpt1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView">
<HeaderTemplate>
<table align="left"><tr><td>
<h1>Results:</h1>
<hr/>
</td></tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left"><asp:LabelID="lblheader"runat="server"style="color:#9e6917; text-align:left; font-size:10pt;"><%# DataBinder.Eval(Container.DataItem, "headers") %></asp:Label></td>
</tr>
<tr>
<td align="left"><asp:Label ID="lbldescription" runat="server" style="color:#000000; text-align:left; font-size:10pt;"> <%# DataBinder.Eval(Container.DataItem, "descriptions") %></asp:Label></td></tr>
<tr>
<td align="left"><ahref="<%# DataBinder.Eval(Container.DataItem, "urls") %>" style="color:#00508e; text-align:left; font-size:10pt;"><asp:Label ID="lblurl" runat="server"><%# DataBinder.Eval(Container.DataItem, "urls") %></asp:Label></a><br/><hr/></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr><td>
End Results
</td></tr>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:[CONNECTIONSTRINGNAME] %>" SelectCommand="[STOREDPROCNAME]" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameter FormField="txtSearchBar" Name="keyword" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</form>
I really didn't need to code anything in the aspx.vb file.... the repeater took care of everything.

Ok, so - if you're still with me and haven't given up on me... I'd like to know how to post this to an I-FRAME on the same page... It's always the simple things that get me... any thoughts or suggestions would be appreciated.
__________________
Need a vacation.

Last edited by mb2000inc; 06-29-2009 at 02:01 PM..
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-29-2009, 05:39 PM Re: Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
Ok, so forget the iFrame... I tried this instead... Now the only problem, is that the parameter that I'm passing for the initial query is not getting passed through to the paging... any thoughts?
Code:
    Private Sub BindData()
        Dim conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("[CONNECTIONSTRING]").ConnectionString)
        conn.Open()
        Dim da As SqlDataAdapter = New SqlDataAdapter("[STOREDPROC]", conn)
        Dim dt As DataTable = New DataTable()
 
        da.Fill(dt) 'THIS IS WHERE THE ERROR HAPPENS - TELLING ME THAT THE PARAMETER IS
       'NOT BEING PASSED - WHEN IT'S INITIALLY PASSED FROM THE TEXT BOX TO THE 
       'REPEATER
 
        ' Populate the repeater control with the datatable
        Dim objPds As PagedDataSource = New PagedDataSource()
        objPds.DataSource = dt.DefaultView
        ' Indicate that the data should be paged
        objPds.AllowPaging = True
        ' Set the pagesize
        objPds.PageSize = 5
        Dim curpage As Integer
        ' we'll use ViewState to track the currentindex
        If Not (ViewState("Page") Is Nothing) Then
            curpage = Convert.ToInt32(ViewState("Page"))
        Else
            ViewState("Page") = 1
            curpage = 1
        End If
        ' Set the currentindex
        objPds.CurrentPageIndex = curpage - 1
        ' Display the current page
        lblPager.Text = "Page: " & (curpage).ToString() & " of " & objPds.PageCount.ToString()
        ' Bind the repeater
        rpt1.DataSource = objPds
        rpt1.DataBind()
    End Sub
    Protected Sub lnkPrev_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Set viewstate variable to the previous page
        ViewState("Page") = Convert.ToInt32(ViewState("Page")) - 1
        ' Reload control
        BindData()
    End Sub
    Protected Sub lnkNext_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Set viewstate variable to the next page
        ViewState("Page") = Convert.ToInt32(ViewState("Page")) + 1
        ' Reload control
        BindData()
    End Sub
Any suggestions?
__________________
Need a vacation.

Last edited by mb2000inc; 06-29-2009 at 05:43 PM..
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-30-2009, 09:59 AM Re: Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
OK, so that's not working out so well...

I tried using a form view and enabled paging... at this point - it works. but only one result per page is coming up. How do I change that to make it more.

Like, I want to have four or five results per page....

Any thoughts?
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 07-17-2009, 11:38 AM Re: Custom Site Search - NOT GOOGLE
Experienced Talker

Posts: 31
Trades: 0
We have used the Ultimate Search tool from Karamasoft on multiple websites. Complete .net based tool. Worth checking out as the license is cheaper than developing an inhouse solution.
__________________
textbox advertising agency
textbox is offline
Reply With Quote
View Public Profile Visit textbox's homepage!
 
Old 07-20-2009, 12:11 PM Re: Custom Site Search - NOT GOOGLE
mb2000inc's Avatar
Super Talker

Posts: 118
Name: Mark
Location: Ohio
Trades: 0
I ended up going with this one and tweaking it to my needs:
http://www.codeproject.com/KB/applic...rchDotnet.aspx

Honestly, it's exactly what I was looking for... I didn't have to add a database, nor did I have to do some SERIOUS code tweaking... I did a few modifications on the code - but it was kind of like a plug-n-play but in the development sense.

I tweaked it's css and some of the functionality - and it was FREE!

I also looked at the Karmasoft thing - and I do like it better, but I don't wanna have to pay for something like that.

But I do appreciate a response. You rock and your talkupation just went up.
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Reply     « Reply to Custom Site Search - NOT GOOGLE
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.23417 seconds with 13 queries