📄 catalogue.aspx
字号:
<%@ Page Language="VB" Inherits="IBuyAdventure.PageBase" src="components/stdpage.vb" %>
<%@ Register TagPrefix="IBA" TagName="Header" Src="UserControl\Header.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Footer" Src="UserControl\Footer.ascx" %>
<%@ Register TagPrefix="IBA" TagName="Categories" Src="UserControl\Categories.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ OutputCache Duration="600" VaryByParam="ProductType" %>
<html>
<head>
<title>IBuyAdventure Catalog</title>
</head>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
' Determine what product category has been specified and update section image
Dim productType As String = Request.Params("ProductType")
CatalogueSectionImage.Src = "images/hd_" & productType & ".gif"
' User business object to fetch category products and databind
' it to a <asp:datalist> control
Dim inventory As New IBuyAdventure.ProductsDB(getConnStr())
MyList.DataSource = inventory.GetProducts(productType)
MyList.DataBind()
End If
End Sub
Sub DataList_ItemBound(sender As Object, e As DataListItemEventArgs)
Dim myRowView As DataRowView
Dim myRow As DataRow
myRowView = e.Item.DataItem
myRow = myRowView.Row
If myRow("OnSale") = 0 Then
e.Item.FindControl("saleItem").Visible = False
End If
CType(e.Item.FindControl("OrderButton"), ImageButton).CommandArgument = myRow("ProductCode").ToString()
CType(e.Item.FindControl("OrderButton"), ImageButton).AlternateText = "Click to order " + myRow("ProductName")
End Sub
Sub OrderButton_Command(sender As Object, e As CommandEventArgs)
If e.CommandName = "Order" Then
Dim prodCode As String = e.CommandArgument.ToString()
Response.Redirect ("ShoppingCart.aspx?ProductCode=" + prodCode)
End If
End Sub
</script>
<body background="images/back_sub.gif">
<form runat="server">
<font face="Verdana, Arial, Helvetica" size="2">
<table border="0">
<tr>
<td colspan="5">
<IBA:Header id="Header" runat="server"/>
</td>
</tr>
<tr>
<td rowspan="5" align="left" valign="top">
<IBA:Categories id="Categories" runat="server"/>
<br><br><br>
</td>
<td valign="top">
<img id="CatalogueSectionImage" runat="server">
<br><br>
<asp:datalist id="MyList" BorderWidth="0" RepeatDirection="horizontal" RepeatColumns="2" runat="server" OnItemDataBound="DataList_ItemBound">
<itemtemplate>
<table>
<tr>
<td align="right" valign="top" width="150">
<img src='<%= Context.Request.ApplicationPath %>/images/<%#DataBinder.Eval(Container.DataItem, "ProductImageURL")%>'>
</td>
<td width="20"> </td>
<td align="left" valign="top">
<font size="2">
<b><a href='<%#DataBinder.Eval(Container.DataItem, "ProductCode", "Details.aspx?ProductCode={0}")%>'>
<%#DataBinder.Eval(Container.DataItem, "ProductName")%></a></B>,
<%#DataBinder.Eval(Container.DataItem, "ProductDescription")%><br><br>
<%#DataBinder.Eval(Container.DataItem, "ProductCode")%>
<br>
<br>
<img src="images/saleTag1.gif" id="saleItem" runat="server" >
<b><%#DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}")%></B>
<br><br>
<asp:ImageButton runat="server" id="OrderButton"
ImageUrl="images/order.gif"
OnCommand="OrderButton_Command"
CommandName="Order"/>
</font>
</td>
</tr>
</table>
</itemtemplate>
</asp:datalist>
</td>
</tr>
<tr>
<td>
<IBA:Footer runat="server" />
</td>
</tr>
</table>
</font>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -