Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The source code for the Commerce Server 2002 SDK ASP.NET-based Catalog Sitelet in Visual Basic .NET


View products that this article applies to.

Introduction

This article contains the source code for the Microsoft Commerce Server 2002 Software Development Kit (SDK) Microsoft ASP.NET-based Catalog Sitelet in Microsoft Visual Basic .NET.

Note The source code for the ASP.NET-based Catalog Sitelet was previously only available in Microsoft Visual C#.

↑ Back to the top


More information

The following code is the source code for the ASP.NET-based Catalog Sitelet in Visual Basic .NET.

Browse.aspx

<%@ Page Description="Browse Page" CodePage="65001" Debug="true"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Catalog"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Configuration"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics"%>
<%@Register TagPrefix="Localized" TagName="Footer" src="footer.ascx" %>
<!---------------------------------------------------------------------
--  File:      browse.aspx
--
--  Summary:   Page used to browse Catalog
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">
			Private rm As ResourceManager 
			Private strLanguage As String = Nothing 
			Private catDisplayName As String = Nothing
			
			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
 				rm = ResourceFactory.RManager 
 				If rm Is Nothing Then 
					'Resources are unavailable.Server.Transfer(Utility.errorPage)
 				End If 
			End Sub

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim SelectedCulture As CultureInfo 
 				Dim coll As NameValueCollection = Request.QueryString 
 				strLanguage = coll(Utility.languageLabel) 

 				Try 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(strLanguage) 
 				Catch e As Exception 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(Utility.englishLanguage) 
   					strLanguage = Utility.englishLanguage 
 				End Try
 
 				Footer.Language = strLanguage 

				' If another culture was selected, use that instead
 				If Not (SelectedCulture Is Nothing) Then 
   					Thread.CurrentThread.CurrentCulture = SelectedCulture 
   					Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 				End If 

 				catDisplayName = Utility.GetDisplayName(Utility.catalogName, strLanguage) 

 				If Not IsPostBack Then 
   					UpdateCategories 
 				End If 
			End Sub

			Sub RootCategoryListing_ItemCommand(ByVal source As Object, ByVal args As RepeaterCommandEventArgs) 
 
				Dim strArg As String = CType(args.CommandArgument, String) 
 				Dim arr As String() = strArg.Split("&"C) 
 				Dim category As String = arr(0) 
 				Dim dispCategory As String = arr(1) 
 				Dim products As DataSet = Nothing 
 				Dim categories As DataSet = Nothing 

				'Get child category and products for given category
 				GetProductListing(category, products, categories) 

 				If Not (0 = products.Tables(0).Rows.Count) Then 
					'List child products for category
   					ProductListing.DataSource = products 
   					ProductListing.DataBind 
   					ProdName.Visible = True 
  	 				ProductListing.Visible = True 
   					ProdName.Text = rm.GetString(Utility.browseProdCategories) & " " & dispCategory 
 				Else 
   					ProdName.Visible = False 
   					ProdName.Text = Nothing 
   					ProductListing.Visible = False 
 				End If 

 				If Not (0 = categories.Tables(0).Rows.Count) Then 
					'List child category for parent category
   					CategoryListing.DataSource = categories 
   					CategoryListing.DataBind 
   					CatName.Visible = True 
   					CategoryListing.Visible = True 
   					CatName.Text = rm.GetString(Utility.browseChildCategories) & " " & dispCategory 
   					Seprator.InnerHtml = "<BR>" 
 				Else 
   					CatName.Visible = False 
   					CatName.Text = Nothing 
   					CategoryListing.Visible = False 
   					Seprator.InnerHtml = Nothing 
 				End If 
			End Sub

			Sub UpdateCategories() 
 				Dim catalog As ProductCatalog = CommerceContext.Current.CatalogSystem.GetCatalog(Utility.catalogName) 
 				RootCategoryListing.DataSource = catalog.GetRootCategories 
 				RootCategoryListing.DataBind 
			End Sub 

			Sub ProductListing_ItemCommand(ByVal source As Object, ByVal args As RepeaterCommandEventArgs) 
 				Response.Redirect(rm.GetString(Utility.productPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage & "&" & Utility.productID & "=" & CType(args.CommandArgument, String)) 
			End Sub 

			Sub GetProductListing(ByVal category As String, ByRef product As DataSet, ByRef categories As DataSet) 
 				Dim catalog As ProductCatalog = CommerceContext.Current.CatalogSystem.GetCatalog(Utility.catalogName) 
 				product = catalog.GetCategory(category).GetProducts 
 				categories = catalog.GetCategory(category).GetChildCategories 
			End Sub
		</script>
		<title>
			<%=rm.GetString(Utility.browsePageTitle) &" "& catDisplayName%>
		</title>
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body>
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.browsePageTitle) &" "& catDisplayName%>
		</DIV>
		<BR>
		<BR>
		<form id="browse" method="post" runat="server">
			<TABLE CELLPADDING="4" CELLSPACING="0" BORDER="0" WIDTH="85%">
				<TR>
					<TD VALIGN="top" BGCOLOR="silver" WIDTH='<%=rm.GetString("Width")%>'>
						<asp:Repeater id="RootCategoryListing" OnItemCommand="RootCategoryListing_ItemCommand" runat="server">
							<HeaderTemplate>
								<B>
									<%= rm.GetString(Utility.browsePageSubTitle)%>
								</B>
								<BR>
							</HeaderTemplate>
							<ItemTemplate>
								<asp:LinkButton id="SelectCategoryBtn" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("CategoryName") & "&" & CType(Container.DataItem, DataRowView)("DisplayName") %>' runat="server">
									<%# DataBinder.Eval(Container.DataItem, "DisplayName") %>
								</asp:LinkButton>
							</ItemTemplate>
							<SeparatorTemplate>
								<BR>
							</SeparatorTemplate>
						</asp:Repeater>
					</TD>
					<TD VALIGN="top">
						<b>
							<asp:Label id="CatName" runat="server" />
						</b>
						<asp:Repeater id="CategoryListing" OnItemCommand="RootCategoryListing_ItemCommand" runat="server">
							<HeaderTemplate>
								<BR>
							</HeaderTemplate>
							<ItemTemplate>
								<asp:LinkButton id="SelectCategory" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("CategoryName") & "&" & CType(Container.DataItem, DataRowView)("DisplayName") %>' runat="server">
									<%# DataBinder.Eval(Container.DataItem, "DisplayName") %>
								</asp:LinkButton>
							</ItemTemplate>
							<SeparatorTemplate>
								<BR>
							</SeparatorTemplate>
						</asp:Repeater>
						<DIV id="Seprator" runat="server" />
						<b>
							<asp:Label id="ProdName" runat="server" />
						</b>
						<asp:Repeater id="ProductListing" OnItemCommand="ProductListing_ItemCommand" runat="server">
							<HeaderTemplate>
								<BR>
							</HeaderTemplate>
							<ItemTemplate>
								<asp:LinkButton id="SelectProductBtn" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("ProductID") %>' runat="server">
									<%# DataBinder.Eval(Container.DataItem, "Name") %>
									<br>
								</asp:LinkButton>
								<asp:Label id="Describe" runat="server">
									<%# DataBinder.Eval(Container.DataItem, "description") %>
								</asp:Label>
							</ItemTemplate>
							<SeparatorTemplate>
								<BR>
								<BR>
							</SeparatorTemplate>
						</asp:Repeater>
					</TD>
				</TR>
			</TABLE>
			<Localized:Footer runat="server" ID="Footer" />
		</form>
	</body>
</HTML>

Default.aspx

<%@Page Description="Default Page" CodePage="65001" %>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Globalization"%>
<!---------------------------------------------------------------------
--  File:      Default.aspx
--
--  Summary:   Language page for Catalog Sitelet
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">
	        	Private rm As ResourceManager 

			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
				'Get the ResourceManager from the Application object
 				rm = ResourceFactory.RManager 
 				
				If rm Is Nothing Then 
					'Resources are unavailable
   					Server.Transfer(Utility.errorPage) 
 				End If 
			End Sub 

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Try 
   					Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0)) 
 				Catch generatedExceptionVariable0 As Exception 
   					'Provide fallback for not supported languages
					Thread.CurrentThread.CurrentCulture = New CultureInfo(Utility.englishLanguage) 
 				End Try 
 
				Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 
				If Not IsPostBack Then 
   					English.Text = rm.GetString(Utility.English) 
   					German.Text = rm.GetString(Utility.German) 
   					French.Text = rm.GetString(Utility.French) 
   					Japanese.Text = rm.GetString(Utility.Japanese) 
   					English.NavigateUrl = rm.GetString(Utility.mainPageUrl) & "?" & Utility.languageLabel & "=" & Utility.englishLanguage 
  	 				German.NavigateUrl = rm.GetString(Utility.mainPageUrl) & "?" & Utility.languageLabel & "=" & Utility.germanLanguage 
   					French.NavigateUrl = rm.GetString(Utility.mainPageUrl) & "?" & Utility.languageLabel & "=" & Utility.frenchLanguage 
   					Japanese.NavigateUrl = rm.GetString(Utility.mainPageUrl) & "?" & Utility.languageLabel & "=" & Utility.japaneseLanguage 
 				End If 
			End Sub
		</script>
		<title>
			<%=rm.GetString(Utility.siteletTitle)%>
		</title>
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.siteletTitle)%>
		</DIV>
		<BR>
		<DIV CLASS="H1">
			<%= rm.GetString(Utility.siteletSubTitle)%>
		</DIV>
		<BR>
		<form id="Languages" method="post" runat="server">
			<UL>
				<LI>
					<asp:Hyperlink id="English" Text="English" runat="server" />
				</LI>
				<LI>
					<asp:Hyperlink id="German" Text="German" runat="server" />
				</LI>				
				<LI>
					<asp:Hyperlink id="French" Text="French" runat="server" />
				</LI>
				<LI>
					<asp:Hyperlink id="Japanese" Text="Japanese" runat="server" />
				</LI>
			</UL>
		</form>
	</body>
</HTML>

Footer.ascx

<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="catalogsitelet" %>
<%@ Control %>
<!---------------------------------------------------------------------
--  File:      footer.ascx
--
--  Summary:   Footer control
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<script runat="server" language="VB">

Private strLanguage As String = Nothing 

Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter) 
	Dim rmgr As ResourceManager = ResourceFactory.RManager 
 
	If Nothing = strLanguage OrElse "" = strLanguage.Trim Then 
   		strLanguage = Utility.englishLanguage 
 	End If 

 	Home.Text = rmgr.GetString("L_HTMLURLText_Home") 
 	Browse.Text = rmgr.GetString("L_HTMLURLText_Footer_Browse") 
 	FTSearch.Text = rmgr.GetString("L_HTMLURLText_Footer_FTSearch") 
 	PropSearch.Text = rmgr.GetString("L_HTMLURLText_Footer_PropSearch") 
 	Home.NavigateUrl = rmgr.GetString(Utility.homePageUrl) 
 	Browse.NavigateUrl = rmgr.GetString(Utility.browsePageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
 	FTSearch.NavigateUrl = rmgr.GetString(Utility.ftSearchPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
 	PropSearch.NavigateUrl = rmgr.GetString(Utility.propSearchPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
 	MyBase.Render(writer) 
End Sub 

Public Property Language() As String 
 	Get 
   		Return strLanguage 
 	End Get 
 	
	Set 
   		strLanguage = value 
 	End Set 
End Property
</script>
<asp:Panel runat="server">
	<BR>
	<asp:Hyperlink id="Home" Text="Home" runat="server" />
	|
	<asp:Hyperlink id="Browse" Text="Browse" runat="server" />
	|
	<asp:Hyperlink id="FTSearch" Text="Full Text Search" runat="server" />
	|
	<asp:Hyperlink id="PropSearch" Text="Property Search" runat="server" />
</asp:Panel>

Ftsearch.aspx

<%@ Page Description="Localized Page" CodePage="65001" %>
<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Catalog"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Configuration"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics"%>
<%@Register TagPrefix="Localized" TagName="Footer" src="footer.ascx" %>
<!---------------------------------------------------------------------
--  File:      ftsearch.aspx
--
--  Summary:   Page performs free text search and displays the result
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">
			Private rm As ResourceManager 
			Private strLanguage As String = Nothing 
			Private catDisplayName As String = Nothing 
			Private searchText As String = Nothing 

			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
				'Get the ResourceManager from the Application object
 				rm = ResourceFactory.RManager 
				If rm Is Nothing Then 
					'Resources are unavailable
   					Server.Transfer(Utility.errorPage) 
 				End If 
			End Sub 

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim SelectedCulture As CultureInfo 
 				Dim coll As NameValueCollection = Request.QueryString 
 				strLanguage = coll(Utility.languageLabel) 
 
				Try 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(strLanguage) 
 				Catch e As Exception 
					'Fallback to English language
   					SelectedCulture = CultureInfo.CreateSpecificCulture(Utility.englishLanguage) 
   					strLanguage = Utility.englishLanguage 
 				End Try 
 				
				'Set Language on footer control
				Footer.Language = strLanguage 
 
				'Set culture for current thread
				If Not (SelectedCulture Is Nothing) Then 
   					Thread.CurrentThread.CurrentCulture = SelectedCulture 
   					Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 				End If 
 
				'Initialize controls with appropriate texts
				Search.Text = rm.GetString(Utility.ftSearchSearch) 

				'Get display name for catalog, write a function
 				catDisplayName = Utility.GetDisplayName(Utility.catalogName, strLanguage) 
			End Sub 

			Sub SearchButton_Click(ByVal sender As Object, ByVal args As EventArgs) 
 				Try 
   					Dim totalRecords As Integer = 0 
   					Dim startPage As Integer = 1 
   					searchText = txtSearchText.Text 
   					
					If searchText.Trim = "" Then 
     						Return 
   					End If 
   
					Dim catalogCtx As CatalogContext = CommerceContext.Current.CatalogSystem 
   					Dim searchResult As DataSet = FreeTextSearch(searchText, startPage, totalRecords) 
   
					If 0 < searchResult.Tables(0).Rows.Count Then 
     						rptSearchResult.Visible = True 
     						rptSearchResult.DataSource = searchResult 
     						rptSearchResult.DataBind 
     						Matches.Text = totalRecords.ToString & " " & rm.GetString(Utility.ftSearchTotal) 
   					Else 
     						rptSearchResult.Visible = False 
     						Seprator.InnerHtml = Nothing 
     						Pages.Text = Nothing 
    					 	Matches.Text = Nothing 
   					End If 
   
					'Do paging
					Paging.Visible = False 
   					If totalRecords > Utility.numberOfRecordToDisplay Then 
     						Dim pagingTable As DataTable = Utility.DoPaging(totalRecords, Utility.numberOfRecordToDisplay, searchText) 
     						Paging.DataSource = pagingTable.DefaultView 
     						Paging.DataBind 
     						Paging.Visible = True 
     						Seprator.InnerHtml = "<BR>" 
     						Pages.Text = rm.GetString(Utility.ftSearchPage) 
   					End If 
 
				Catch e As Exception 
					'Eat exception
 				End Try 
			End Sub 

			'Page click response
			Sub PageClick_ItemCommand(ByVal sender As Object, ByVal args As RepeaterCommandEventArgs) 
 				Dim searchClause As String = CType(args.CommandArgument, String) 
 				Dim totalRecords As Integer = 0 
 				Dim page As Integer = args.Item.ItemIndex + 1 
 				Dim searchResult As DataSet = FreeTextSearch(searchText, page, totalRecords) 
 
				'If products found
				If 0 < searchResult.Tables(0).Rows.Count Then 
   					rptSearchResult.Visible = True 
   					rptSearchResult.DataSource = searchResult 
   					rptSearchResult.DataBind 
   					Seprator.InnerHtml = "<BR>" 
   					Pages.Text = rm.GetString(Utility.ftSearchPage) 
   					Matches.Text = totalRecords.ToString & " " & rm.GetString(Utility.ftSearchTotal) 
 				Else 
   					rptSearchResult.Visible = False 
   					Seprator.InnerHtml = Nothing 
   					Pages.Text = Nothing 
 				End If 
			End Sub 

			Function FreeTextSearch(ByVal searchstring As String, ByVal page As Integer, ByRef totalRecords As Integer) As DataSet 
 				
				'Search Options
				Dim searchOptions As CatalogSearchOptions = Utility.SetSearchOptions(page, Utility.numberOfRecordToDisplay, "name") 
	 			'Look for the products supporting search criteria
				Dim search As CatalogSearch = New CatalogSearch(CommerceContext.Current.CatalogSystem) 
 				
				search.CatalogNames = Utility.catalogName 
 				search.FreeTextSearchPhrase = searchstring 
 				search.SearchOptions = searchOptions 
 				Return search.Search(totalRecords) 
			End Function 

			Sub ProductListing_ItemCommand(ByVal sender As Object, ByVal args As RepeaterCommandEventArgs) 
 				Response.Redirect(rm.GetString(Utility.productPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage & "&" & Utility.productID & "=" & CType(args.CommandArgument, String)) 
			End Sub					
		</script>
		<title>
			<%=rm.GetString(Utility.ftPageTitle) & " " & catDisplayName%>
		</title>
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body>
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.ftPageTitle) & " " & catDisplayName%>
		</DIV>
		<form id="ftsearch" method="post" runat="server">
			<asp:TextBox id="txtSearchText" runat="server"></asp:TextBox>
			<input type=text style="visibility:hidden" runat="server"/>
			<BR>
			<asp:Button id="Search" runat="server" Text="Search" OnClick="SearchButton_Click"></asp:Button>
			<br>
			<br>
			<asp:Label id="Matches" runat="server" />
			<br>
			<br>
			<asp:Repeater id="rptSearchResult" OnItemCommand="ProductListing_ItemCommand" runat="server">
				<ItemTemplate>
					<asp:LinkButton id="SelectProductBtn" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("ProductID") %>' runat="server">
						<%# DataBinder.Eval(Container.DataItem, "Name") %>
					</asp:LinkButton>
					&nbsp; (
					<asp:Label id="Describe" runat="server">
						<%# DataBinder.Eval(Container.DataItem, "description") %>
					</asp:Label>
					)
				</ItemTemplate>
				<SeparatorTemplate>
					<BR>
					<br>
				</SeparatorTemplate>
			</asp:Repeater>
			<DIV id="Seprator" runat="server" />
			<asp:Label id="Pages" runat="server" />
			<asp:Repeater id="Paging" OnItemCommand="PageClick_ItemCommand" runat="server">
				<ItemTemplate>
					<asp:LinkButton id="PageClick" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("Clause") %>' runat="server">
						<%# DataBinder.Eval(Container.DataItem, "Page") %>
					</asp:LinkButton>
				</ItemTemplate>
			</asp:Repeater>
			<Localized:Footer runat="server" id="Footer" />
		</form>
	</body>
</HTML>

Global.ascx

<%@Import namespace="System"%>
<%@Import namespace="System.Collections"%>
<%@Import namespace="System.ComponentModel"%>
<%@Import namespace="System.Web"%>
<%@Import namespace="System.Web.SessionState"%>
<%@Import namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import namespace="System.IO"%>
<%@Import namespace="System.Resources"%>
<%@Import namespace="System.Threading"%>
<%@Import namespace="System.Globalization"%>

<script runat="server" language="VB">

	Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub 

	Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub 

	Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub 

	Sub Application_EndRequest(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub 

	Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub 

	Sub InitializeComponent() 
	End Sub 

	Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) 
	End Sub

</script>

Main.aspx

<%@Page Description="Localized Page" CodePage="65001" %>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Catalog"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Configuration"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics"%>
<%@Register TagPrefix="Localized" TagName="Footer" src="footer.ascx" %>
<!---------------------------------------------------------------------
--  File:      main.aspx
--
--  Summary:   Main selection page for Catalog Sitelet
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">
			Private rm As ResourceManager 
			Private strLanguage As String = Nothing 

			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
				'Get the ResourceManager from the Application object
 				rm = ResourceFactory.RManager 
 				If rm Is Nothing Then 
					'Resources are unavailable
  	 				Server.Transfer(Utility.errorPage) 
 				End If 
			End Sub 

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim SelectedCulture As CultureInfo 
 				Dim coll As NameValueCollection = Request.QueryString 
 				strLanguage = coll(Utility.languageLabel) 
 
				Try 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(strLanguage) 
 				Catch e As Exception 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(Utility.englishLanguage) 
   					strLanguage = Utility.englishLanguage 
 				End Try 
 
				Footer.Language = strLanguage 
 
				If Not (SelectedCulture Is Nothing) Then 
   					Thread.CurrentThread.CurrentCulture = SelectedCulture 
   					Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 				End If 
 				
				If Not IsPostBack Then 
  	 				BrowseCat.Text = rm.GetString(Utility.browsePageLabel) 
   					FullTextSearch.Text = rm.GetString(Utility.ftSearchLabel) 
   					PropertySearch.Text = rm.GetString(Utility.propSearchLabel) 
   					BrowseCat.NavigateUrl = rm.GetString(Utility.browsePageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
   					FullTextSearch.NavigateUrl = rm.GetString(Utility.ftSearchPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
   					PropertySearch.NavigateUrl = rm.GetString(Utility.propSearchPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage 
 				End If 
			End Sub
		</script>
		<title>
			<%=rm.GetString(Utility.pageTitle)%>
		</title>
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body>
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.pageTitle)%>
		</DIV>
		<BR>
		<BR>
		<form id="main" method="post" runat="server">
			<ul>
				<li>
					<asp:Hyperlink id="BrowseCat" Text="Browse the Catalog" runat="server" />
				</li>
				<li>
					<asp:Hyperlink id="FullTextSearch" Text="Perform a Full Text Search" runat="server" />
				</li>
				<li>
					<asp:Hyperlink id="PropertySearch" Text="Perform a Property Search" runat="server" />
				</li>
			</ul>
			<Localized:Footer runat="Server" ID="Footer" />
		</form>
	</body>
</HTML>

Noresource.aspx

<%@ Page %>
<!---------------------------------------------------------------------
--  File:      noresource.aspx
--
--  Summary:   Shown when no resource manager found
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<html>
<head>
<title>Server Error</title>
</head>
<body>
<h1>Server Error</h1>

Localized resources were not available.<p>
Please contact the administrator.

</body>
</html>

Product.aspx

<%@ Page Description="Localized Page" CodePage="65001" %>
<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System"%>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Catalog"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Configuration"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics"%>
<%@Import Namespace="System.Data"%>
<%@Register TagPrefix="Localized" TagName="Footer" src="footer.ascx" %>
<!---------------------------------------------------------------------
--  File:      product.aspx
--
--  Summary:   Page is used to display product details
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">
			Private rm As ResourceManager 
			Private strLanguage As String = Nothing 
			Private catalog As ProductCatalog = Nothing 
			Private productdt As DataRow = Nothing 
			Private productDisplayName As String = Nothing 

			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
				'ResourceManager from the Application object
 				rm = ResourceFactory.RManager 
 				catalog = CommerceContext.Current.CatalogSystem.GetCatalog(Utility.catalogName) 
 
				If rm Is Nothing Then 
					'Resources are unavailable
   					Server.Transfer(Utility.errorPage) 
 				End If 
			End Sub 

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim SelectedCulture As CultureInfo 
 				Dim coll As NameValueCollection = Request.QueryString 
 				strLanguage = coll(Utility.languageLabel) 
 
				Try 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(strLanguage) 
 				Catch e As Exception 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(Utility.englishLanguage) 
   					strLanguage = Utility.englishLanguage 
 				End Try 
 
				Footer.Language = strLanguage 
 				catalog.ActiveLanguage = strLanguage 
 
				If Not (SelectedCulture Is Nothing) Then 
   					Thread.CurrentThread.CurrentCulture = SelectedCulture 
   					Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 				End If 
 		
				Dim productid As String = coll(Utility.productID) 
 
				If Not IsPostBack AndAlso Not (productid Is Nothing) Then 
   					Try 
     						Dim myProduct As Product = catalog.GetProduct(productid) 
     						Dim data As DataSet = myProduct.GetProductProperties 
     						productdt = data.Tables(0).Rows(0) 
     
						Try 
       							productDisplayName = CType(productdt("name"), String) 
     						Catch e As Exception 
       							productDisplayName = "" 
     						End Try 
     
						Try 
       							ProductImage.ImageUrl = CType(productdt("Image_filename"), String) 
     						Catch e As Exception 
       							ProductImage.ImageUrl = Nothing 
     						End Try 
     						
						Try 
       							ProductIDLabel.Text = CType(productdt("name"), String) 
     						Catch e As Exception 
       							ProductIDLabel.Text = Nothing 
     						End Try 
     
						Try 
       							IntroDateLabel.Text = rm.GetString(Utility.productPageIntro) 
       							Dim dateTime As DateTime = CType(productdt("IntroductionDate"), DateTime) 
       							IntroDate.Text = dateTime.ToShortDateString 
     						Catch e As Exception 
       							IntroDateLabel.Text = Nothing 
     						End Try 
    
		 				Try 
       							PriceLabel.Text = rm.GetString(Utility.productPagePrice) 
       							Price.Text = "$" & productdt("cy_list_price").ToString 
     						Catch e As Exception 
       							PriceLabel.Text = Nothing 
     						End Try 
     
						Try 
       							ProductCodeLabel.Text = rm.GetString(Utility.productPageCode) 
       							ProductCode.Text = productdt("ProductCode").ToString 
     						Catch e As Exception 
       							ProductCodeLabel.Text = Nothing 
     						End Try 
     
						Try 
       							Dim variantData As DataSet = myProduct.GetVariants 
       							VariantListing.DataSource = variantData 
       							VariantListing.DataBind 
       
							If Not (0 = variantData.Tables(0).Rows.Count) Then 
         							Variants.Text = rm.GetString(Utility.productPageColor) 
       							Else 
         							Variants.Text = Nothing 
       							End If 
     						Catch e As Exception 
       							Variants.Text = Nothing 
     						End Try 
     
						Try 
       							DescribeLabel.Text = rm.GetString(Utility.productPageDescription) 
       							Description.Text = CType(productdt("Description"), String) 
     						Catch e As Exception 
       							DescribeLabel.Text = Nothing 
     						End Try 
     
						Try 
       							Size.Text = CType(productdt("ProductSize").ToString, String) 
       							
							If Not ("" = Size.Text.Trim) Then 
         							SizeLabel.Text = rm.GetString(Utility.productPageSize) 
       							End If 
     						Catch e As Exception 
       							SizeLabel.Text = Nothing 
     						End Try 
     
						Try 
       							Dim available As Integer = CType(productdt("OnSale"), Integer) 
       
							If 1 = available Then 
         							AvailableLabel.Text = rm.GetString(Utility.productPageAvailable) 
       							Else 
         							AvailableLabel.Text = rm.GetString(Utility.productPageUnavailable) 
       							End If 
     						Catch e As Exception 
       							AvailableLabel.Text = Nothing 
     						End Try 
   					Catch e As Exception
						'Eat exception 
   					End Try 
 				End If 
			End Sub

		</script>
		<title>
			<%=rm.GetString(Utility.productPageTitle) & " " & productDisplayName%>
		</title>		
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body>
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.productPageTitle) & " " & productDisplayName%>
		</DIV>
		<BR>
		<BR>
		<form id="Productform" method="post" runat="server">
			<asp:Table id="Product" runat="server" Width="50%" cellpadding="2" cellspacing="0" Height="175px">
				<asp:TableRow>
					<asp:TableCell ColumnSpan="100">
						<B>
							<asp:Label ID="ProductIDLabel" Runat="server" />
						</B>
						<br>
						<asp:Label ID="IntroDateLabel" Runat="server" />
						<asp:Label ID="IntroDate" Runat="server" />
						<br>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell ColumnSpan="70">
						<asp:Image id="ProductImage" runat="server"></asp:Image>
					</asp:TableCell>
					<asp:TableCell ColumnSpan="30">
						<b>
							<asp:Label ID="PriceLabel" Runat="server" />
						</b>
						<asp:Label ID="Price" Runat="server" />
						<br>
						<b>
							<asp:Label ID="ProductCodeLabel" Runat="server" />
						</b>
						<asp:Label ID="ProductCode" Runat="server" />
						<br>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell ColumnSpan="100">
						<B>
							<asp:Label ID="Variants" Runat="server" />
						</B>
						<br>
						<asp:Repeater id="VariantListing" runat="server">
							<ItemTemplate>
								<asp:Label id="Color" runat="server">
									<%# DataBinder.Eval(Container.DataItem, "ProductColor") %>
								</asp:Label>
							</ItemTemplate>
							<SeparatorTemplate>
								<BR>
							</SeparatorTemplate>
						</asp:Repeater>
						<BR>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell ColumnSpan="100">
						<B>
							<asp:Label ID="DescribeLabel" Runat="server" />
						</B>
						<BR>
						<asp:Label ID="Description" Runat="server" />
						<BR>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell ColumnSpan="100">
						<B>
							<asp:Label ID="SizeLabel" Runat="server" />
						</B>
						<asp:Label ID="Size" Runat="server" />
						<BR>
					</asp:TableCell>
				</asp:TableRow>
			</asp:Table>
			<asp:Label ID="AvailableLabel" Runat="server" />
			<Localized:Footer runat="server" id="Footer" />
		</form>
	</body>
</HTML>

Propsearch.aspx

<%@Register TagPrefix="Localized" TagName="Footer" src="footer.ascx" %>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Catalog"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Configuration"%>
<%@Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics"%>
<%@Import Namespace="catalogsitelet"%>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System.Resources"%>
<%@Import Namespace="System.Globalization"%>
<%@ Page Description="Localized Page" CodePage="65001" %>
<!---------------------------------------------------------------------
--  File:      propsearch.aspx
--
--  Summary:   Page performs property search and displays the result
--
--  Sample:    Catalog Sitelet
--
-----------------------------------------------------------------------
--  This file is part of the Microsoft Commerce Server 2002 SDK
--
--  Copyright (C) 2002 Microsoft Corporation.  All rights reserved.
--
-- This source code is intended only as a supplement to Microsoft
-- Commerce Server 2002 and/or on-line documentation. See these other
-- materials for detailed information regarding Microsoft code samples.
--
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
-- KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
---------------------------------------------------------------------->
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="VB">
		<meta name="vs_defaultClientScript" content="JavaScript (ECMAScript)">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script runat="Server" Language="VB">		
			Private rm As ResourceManager 
			Private strLanguage As String = Nothing 
			Private catDisplayName As String = Nothing 
			Private productCode As String = Nothing 
			Private introductionDate As String = Nothing 
			Private productName As String = Nothing 

			Sub Page_Init(ByVal sender As Object, ByVal args As EventArgs) 
				'Get the ResourceManager from the Application object
 				rm = ResourceFactory.RManager 
 
				If rm Is Nothing Then 
   					'Do something sensible if resources are unavailable
   					Server.Transfer(Utility.errorPage) 
 				End If 
			End Sub 

			Sub Page_Load(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim SelectedCulture As CultureInfo 
 				Dim coll As NameValueCollection = Request.QueryString 
 				strLanguage = coll(Utility.languageLabel) 
 				
				Try 
   					SelectedCulture = CultureInfo.CreateSpecificCulture(strLanguage) 
 				Catch e As Exception 
					'Fallback to English language
   					SelectedCulture = CultureInfo.CreateSpecificCulture(Utility.englishLanguage) 
   					strLanguage = Utility.englishLanguage 
 				End Try 

				'Set Language on footer control
 				Footer.Language = strLanguage 
					
				'Set culture for current thread
 				If Not (SelectedCulture Is Nothing) Then 
   					Thread.CurrentThread.CurrentCulture = SelectedCulture 
   					Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture 
 				End If
		
				'Initialize controls with appropriate texts 
 				ProdCode.Text = rm.GetString(Utility.productPageCode) 
 				IntroDate.Text = rm.GetString(Utility.propSearchIntro) 
 				Name.Text = rm.GetString(Utility.propSearchTitle) 
 				Button.Text = rm.GetString(Utility.ftSearchSearch) 
 				catDisplayName = Utility.GetDisplayName(Utility.catalogName, strLanguage) 
			End Sub 

			Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs) 
 				Dim searchClause As String = Nothing 
 				
				Try 
					'To keep count of records found
   					Dim totalRecords As Integer = 0 
   					Dim startPage As Integer = 1

					'Product code
   					productCode = ProdCodeText.Text.Trim 
					If Not ("" = productCode) Then 
     						BuildClause(searchClause, "productcode", productCode, False) 
   					End If 
   
					'Introduction date
					introductionDate = IntroDateText.Text.Trim 
					If Not ("" = introductionDate) Then 
     						BuildClause(searchClause, "introductiondate", introductionDate, True) 
   					End If 
   		
					'Product name
					productName = NameText.Text.Trim 
					If Not ("" = productName) Then 
     						BuildClause(searchClause, "name", productName, False) 
   					End If 
   
					Dim searchResult As DataSet = PropertySearch(searchClause, startPage, totalRecords) 
					Paging.Visible = False 

   					'If products found
					If Not (searchResult Is Nothing) AndAlso 0 < searchResult.Tables(0).Rows.Count Then 
     						SearchResultRepeater.Visible = True 
     						SearchResultRepeater.DataSource = searchResult 
    	 					SearchResultRepeater.DataBind 
     						Matches.Text = totalRecords.ToString & " " & rm.GetString(Utility.propSearchTotal) 
   					Else 
     						SearchResultRepeater.Visible = False 
     						Seprator.InnerHtml = Nothing 
     						Pages.Text = Nothing 
     						Matches.Text = Nothing 
   					End If 
   
					'Do paging
					If totalRecords > Utility.numberOfRecordToDisplay Then 
     						Dim pagingTable As DataTable = Utility.DoPaging(totalRecords, Utility.numberOfRecordToDisplay, searchClause) 
     						Paging.DataSource = pagingTable.DefaultView 
    						Paging.DataBind 
     						Paging.Visible = True 
     						Seprator.InnerHtml = "<BR>" 
     						Pages.Text = rm.GetString(Utility.ftSearchPage) 
   					End If 
   
					ProdCodeText.Text = Nothing 
   					IntroDateText.Text = Nothing 
   					NameText.Text = Nothing 
 				Catch e As Exception 
					'Eat exception
 				End Try 
			End Sub 

			'Redirects to product page
			Sub ProductListing_ItemCommand(ByVal sender As Object, ByVal args As RepeaterCommandEventArgs) 
		 		Response.Redirect(rm.GetString(Utility.productPageUrl) & "?" & Utility.languageLabel & "=" & strLanguage & "&" & Utility.productID & "=" & CType(args.CommandArgument, String)) 
			End Sub 

			'Page click response
			Sub PageClick_ItemCommand(ByVal sender As Object, ByVal args As RepeaterCommandEventArgs) 
 				Dim searchClause As String = CType(args.CommandArgument, String) 
 				Dim totalRecords As Integer = 0 
 				Dim page As Integer = args.Item.ItemIndex + 1 
 				Dim searchResult As DataSet = PropertySearch(searchClause, page, totalRecords) 

				'If products found
 				If 0 < searchResult.Tables(0).Rows.Count Then 
   					SearchResultRepeater.Visible = True 
   					SearchResultRepeater.DataSource = searchResult 
   					SearchResultRepeater.DataBind 
   					Seprator.InnerHtml = "<BR>" 
   					Pages.Text = rm.GetString("L_Page_FTSearch_Page") 
   					Matches.Text = totalRecords.ToString & " " & rm.GetString(Utility.propSearchTotal) 
 				Else 
   					SearchResultRepeater.Visible = False 
   					Seprator.InnerHtml = Nothing 
   					Pages.Text = Nothing 
 				End If 
			End Sub 

			'Creates Where clause for SQL statement
			Public Sub BuildClause(ByRef searchCaluse As String, ByVal sKey As String, ByVal sValue As String, ByVal bEquals As Boolean) 
 				If bEquals Then 
   					If searchCaluse Is Nothing Then 
     						searchCaluse = sKey & " = N" & "'" & sValue & "'" 
   					Else 
     						searchCaluse = searchCaluse & " or " & sKey & " = N" & "'" & sValue & "'" 
   					End If 
 				Else 
   					If searchCaluse Is Nothing Then 
     						searchCaluse = sKey & " like N" & "'" & sValue & "'" 
   					Else 
     						searchCaluse = searchCaluse & " or " & sKey & " like N" & "'" & sValue & "'" 
   					End If 
 				End If 
			End Sub 

			Function PropertySearch(ByVal searchstring As String, ByVal page As Integer, ByRef totalRecords As Integer) As DataSet 
				'Search Options 
				Dim searchOptions As CatalogSearchOptions = Utility.SetSearchOptions(page, Utility.numberOfRecordToDisplay, "name") 
				'Look for the products supporting search criteria
 				Dim search As CatalogSearch = New CatalogSearch(CommerceContext.Current.CatalogSystem) 
 
				search.CatalogNames = Utility.catalogName 
 				search.SqlWhereClause = searchstring 
 				search.SearchOptions = searchOptions 
 				Return search.Search(totalRecords) 
			End Function

		</script>
		<title>
			<%=rm.GetString(Utility.propPageTitle) & " " & catDisplayName%>
		</title>
		<LINK REL="stylesheet" TYPE="text/css" HREF="sitelet.css">
	</HEAD>
	<body>
		<DIV CLASS="Heading">
			<%= rm.GetString(Utility.propPageTitle) & " " & catDisplayName%>
		</DIV>
		<form id="propSearch" method="post" runat="server">
			<BR>
			<asp:Table id="display" runat="server">
				<asp:TableRow>
					<asp:TableCell>
						<asp:Label id="ProdCode" runat="server">Product Code:</asp:Label>
					</asp:TableCell>
					<asp:TableCell>
						<asp:TextBox id="ProdCodeText" runat="server"></asp:TextBox>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell>
						<asp:Label id="IntroDate" runat="server">Introduction date:</asp:Label>
					</asp:TableCell>
					<asp:TableCell>
						<asp:TextBox id="IntroDateText" runat="server"></asp:TextBox>
					</asp:TableCell>
				</asp:TableRow>
				<asp:TableRow>
					<asp:TableCell>
						<asp:Label id="Name" runat="server">Name:</asp:Label>
					</asp:TableCell>
					<asp:TableCell>
						<asp:TextBox id="NameText" runat="server"></asp:TextBox>
					</asp:TableCell>
				</asp:TableRow>
			</asp:Table>
			<asp:Button id="Button" runat="server" Text="Button" OnClick="Button_Click" />
			<br>
			<br>
			<asp:Label id="Matches" runat="server" />
			<br>
			<br>
			<asp:Repeater id="SearchResultRepeater" OnItemCommand="ProductListing_ItemCommand" runat="server">
				<ItemTemplate>
					<asp:LinkButton id="SelectProductBtn" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("ProductID") %>' runat="server">
						<%# DataBinder.Eval(Container.DataItem, "Name") %>
					</asp:LinkButton>
					&nbsp; (
					<asp:Label id="Describe" runat="server">
						<%# DataBinder.Eval(Container.DataItem, "description") %>
					</asp:Label>
					)
				</ItemTemplate>
				<SeparatorTemplate>
					<BR>
					<BR>
				</SeparatorTemplate>
			</asp:Repeater>
			<DIV id="Seprator" runat="server" />
			<asp:Label id="Pages" runat="server" />
			<asp:Repeater id="Paging" OnItemCommand="PageClick_ItemCommand" runat="server">
				<ItemTemplate>
					<asp:LinkButton id="PageClick" CommandName="Select" CommandArgument='<%# CType(Container.DataItem, DataRowView)("Clause") %>' runat="server">
						<%# DataBinder.Eval(Container.DataItem, "Page") %>
					</asp:LinkButton>
				</ItemTemplate>
			</asp:Repeater>
			<Localized:Footer runat="server" id="Footer" />
		</form>
	</body>
</HTML>

↑ Back to the top


References

For more information about the ASP.NET-based Catalog Sitelet, visit the following Microsoft Developer Network (MSDN) Web site:

↑ Back to the top


Keywords: KB910309, kbcode, kbhowto, kbinfo, kbprogramming

↑ Back to the top

Article Info
Article ID : 910309
Revision : 4
Created on : 3/16/2007
Published on : 3/16/2007
Exists online : False
Views : 490