rumblepup
02-16-2007, 08:00 PM
Hey guys. Trying to alter a pre-made e-commerce application slightly.
I have a control that is used for a very "simple search"
Here's the code for the simplesearch.ascx
<%@ Control Language="vb" enableViewState="False" AutoEventWireup="false" Codebehind="SimpleSearch.ascx.vb" Inherits="StoreFront.StoreFront.SimpleSearch" TargetSchema="http://schemas.microsoft.com/intellisense/nav4-0" %>
<asp:Panel Runat="server" CssClass="<%=CssCls%>" HorizontalAlign="Center" BorderWidth="0" id="Panel1">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD class="<%=CssCls%>"> </TD>
<TD class="<%=CssCls%>" noWrap width="100%">Search:</TD>
</TR>
<TR>
<TD class="<%=CssCls%>"> </TD>
<TD class="<%=CssCls%>" noWrap>
<asp:TextBox id="txtSimpleSearch" CssClass="Content" Columns="12" runat="server" size="12"></asp:TextBox>
<asp:LinkButton id="btnSearch" Runat="server">
<asp:Image BorderWidth="0" ID="imgSearch" Runat="server" AlternateText="Search"></asp:Image>
</asp:LinkButton></TD>
<TD class="<%=CssCls%>"> </TD>
</TR>
</TABLE>
</asp:Panel>
And here's the code for the ascx.vb
Imports System.Xml
Imports StoreFront.BusinessRule
Imports StoreFront.SystemBase
Public MustInherit Class SimpleSearch
Inherits CWebControl
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents btnSearch As System.Web.UI.WebControls.LinkButton
Protected WithEvents imgSearch As System.Web.UI.WebControls.Image
Protected WithEvents txtSimpleSearch As System.Web.UI.WebControls.TextBox
Private mCss As String = "RightColumn"
Event SimpleSearch_Click As EventHandler
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
imgSearch.ImageUrl = dom.Item("SiteProducts").Item("SiteImages").Item("Search").Attributes("Filepath").Value
If Me.Parent.NamingContainer.ToString.ToLower.IndexOf("rightcolumnnav") >= 0 Then
mCss = "RightColumnText"
ElseIf Me.Parent.NamingContainer.ToString.ToLower.IndexOf("leftcolumnnav") >= 0 Then
mCss = "LeftColumnText"
Else
mCss = "Content"
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim i As Integer
Dim oAdmin As New Admin.CStore(StoreFrontConfiguration.AdminStore)
Dim sLink As String
sLink = oAdmin.DomainName & "SearchResult.aspx?KeyWords=" & txtSimpleSearch.Text
Response.Redirect(sLink)
End Sub
Public Property CssCls() As String
Get
Return mCss
End Get
Set(ByVal Value As String)
mCss = Value
End Set
End Property
End Class
Ok, here are the two things I want to do.
1. I want to capture whatever a user enters into this search field to a database. I want to see what people are searching on my site, as well as render a "search cloud" on a different page.
2. I also want to alter the way my searchresults.aspx page writes it's url. Right now, is looks like this
/SearchResult.aspx?KeyWords=this%20search%20term
but it also works, and I'd like for it to render like
/SearchResult.aspx?KeyWords=this+search+term
Now, I think the answer lies in this line of code
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim i As Integer
Dim oAdmin As New Admin.CStore(StoreFrontConfiguration.AdminStore)
Dim sLink As String
sLink = oAdmin.DomainName & "SearchResult.aspx?KeyWords=" & txtSimpleSearch.Text
Response.Redirect(sLink)
End Sub
How can I get rid of the %20 (which is just and empty space) and render a "+" sign?
I have a control that is used for a very "simple search"
Here's the code for the simplesearch.ascx
<%@ Control Language="vb" enableViewState="False" AutoEventWireup="false" Codebehind="SimpleSearch.ascx.vb" Inherits="StoreFront.StoreFront.SimpleSearch" TargetSchema="http://schemas.microsoft.com/intellisense/nav4-0" %>
<asp:Panel Runat="server" CssClass="<%=CssCls%>" HorizontalAlign="Center" BorderWidth="0" id="Panel1">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD class="<%=CssCls%>"> </TD>
<TD class="<%=CssCls%>" noWrap width="100%">Search:</TD>
</TR>
<TR>
<TD class="<%=CssCls%>"> </TD>
<TD class="<%=CssCls%>" noWrap>
<asp:TextBox id="txtSimpleSearch" CssClass="Content" Columns="12" runat="server" size="12"></asp:TextBox>
<asp:LinkButton id="btnSearch" Runat="server">
<asp:Image BorderWidth="0" ID="imgSearch" Runat="server" AlternateText="Search"></asp:Image>
</asp:LinkButton></TD>
<TD class="<%=CssCls%>"> </TD>
</TR>
</TABLE>
</asp:Panel>
And here's the code for the ascx.vb
Imports System.Xml
Imports StoreFront.BusinessRule
Imports StoreFront.SystemBase
Public MustInherit Class SimpleSearch
Inherits CWebControl
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents btnSearch As System.Web.UI.WebControls.LinkButton
Protected WithEvents imgSearch As System.Web.UI.WebControls.Image
Protected WithEvents txtSimpleSearch As System.Web.UI.WebControls.TextBox
Private mCss As String = "RightColumn"
Event SimpleSearch_Click As EventHandler
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
imgSearch.ImageUrl = dom.Item("SiteProducts").Item("SiteImages").Item("Search").Attributes("Filepath").Value
If Me.Parent.NamingContainer.ToString.ToLower.IndexOf("rightcolumnnav") >= 0 Then
mCss = "RightColumnText"
ElseIf Me.Parent.NamingContainer.ToString.ToLower.IndexOf("leftcolumnnav") >= 0 Then
mCss = "LeftColumnText"
Else
mCss = "Content"
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim i As Integer
Dim oAdmin As New Admin.CStore(StoreFrontConfiguration.AdminStore)
Dim sLink As String
sLink = oAdmin.DomainName & "SearchResult.aspx?KeyWords=" & txtSimpleSearch.Text
Response.Redirect(sLink)
End Sub
Public Property CssCls() As String
Get
Return mCss
End Get
Set(ByVal Value As String)
mCss = Value
End Set
End Property
End Class
Ok, here are the two things I want to do.
1. I want to capture whatever a user enters into this search field to a database. I want to see what people are searching on my site, as well as render a "search cloud" on a different page.
2. I also want to alter the way my searchresults.aspx page writes it's url. Right now, is looks like this
/SearchResult.aspx?KeyWords=this%20search%20term
but it also works, and I'd like for it to render like
/SearchResult.aspx?KeyWords=this+search+term
Now, I think the answer lies in this line of code
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim i As Integer
Dim oAdmin As New Admin.CStore(StoreFrontConfiguration.AdminStore)
Dim sLink As String
sLink = oAdmin.DomainName & "SearchResult.aspx?KeyWords=" & txtSimpleSearch.Text
Response.Redirect(sLink)
End Sub
How can I get rid of the %20 (which is just and empty space) and render a "+" sign?