Back-end Management Tasks for an ASP.NET AJAX Server-Centric Based Online Shopping Website - About Viewing Products
(Page 6 of 6 )
About Viewing Products
Finally, when you click the hyperlink that relates to the product name in the "ProductManage.aspx" page, you will be redirected to the "ProductInfo.aspx" page to view the detailed info about the selected product. Here, we only talk about how to view the image of the product.
First, let’s see the related HTML code, as follows:
<tr style="height:30px;">
<td align="right" style="width:150px;height:30px;">
Picture:</td>
<td align="left" style="height: 100px;">
<asp:GridView ID="GridView1" runat="server" Height="1px" Width="218px" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Image ID="ProductPicture" Runat="server" Width="90" Height="80"
ImageUrl='<%# Eval("PictureID", "../../Handler.ashx?Id={0}") %>' >
</asp:Image>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnShow" runat="server" Text="Display Image"
OnClick="btnShow_Click" />
</td>
</tr>
As has been pointed out in the previous section, to show an image/picture on a web page in a specified position was once very different. But now with the introduction of the new HTTP handler file ".ashx," this problem can be solved relatively easily. Here, we use an ASP.NET GridView control to anchor the position. And then, by using the ASP.NET Imagecontrol and letting its ImageUrlparameter point to a special "Handler.ashx?Id=… " URL and programming the "Handler.ashx" file, we finally achieve the result of displaying the image on the screen.
The following Figure 32 shows part of the design-time snapshot for showing the image data.
Figure 32—the design-time snapshot for showing image data
/Building_ASP.NET_AJAX_Server-Centric_Shopping_Website(8)_html_3d8673cf.png)
Last but not least, only by clicking the "Display Image" can you see the image. If you do not click the button, you will not see the image.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |