E:\web\learnaspcom\htdocs\freebook\learn\ubtoc.xml LearnAsp.com - ASP ASP.net Free Lessons
Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
xxx

C# - Amazon User Control by Charles Carroll

Here is the page that dispays the Amazon book covers

   filename=/experiments/cs_amazon/testbooks.aspx

<Test Script Below>


<%@ Register TagPrefix="bookshow" tagname="cover" src="amazon.ascx"%>
<html><head>
<title>Amazon Test</title>
</head>
<body>
<bookshow:cover ISBN="0517887290" promocode="learnasp" runat="server"/><br>
<bookshow:cover ISBN="0385484992" promocode="learnasp" runat="server"/><br>
<bookshow:cover ISBN="0451169530" promocode="learnasp" 
    height=210 width=160 runat="server"/><br>
<bookshow:cover ISBN="0553283685" promocode="learnasp" 
    height=210 width=160 runat="server"/><br>
</body>
</html>

Here is the User Control that does all the work

filename=/experiments/cs_amazon/amazon.ascx


<script runat="server" language="c#">
    public string Isbn;
    public int Height=80;
    public int Width=55;
    public string LocalGraphic=null;
    public string PromoCode="learnasp";
protected void Page_Load(Object S, EventArgs E)
    {
    Book.NavigateUrl="http://www.amazon.com/exec/obidos/ISBN=" +
        Isbn + "/" + PromoCode;
    if (LocalGraphic==null)
        {
        BookCover.ImageUrl="http://images.amazon.com/images/P/"
        + Isbn  + ".01.MZZZZZZZ.jpg";
        }
    else
        {
        BookCover.ImageUrl=LocalGraphic;
        }
    BookCover.AlternateText="Amazon:" +  Isbn;
    BookCover.Height=Unit.Pixel(Height);
    BookCover.Width=Unit.Pixel(Width);
    }
</script>
<asp:hyperlink id="Book" runat="server">
<asp:Image ID="BookCover" runat="server" />
</asp:hyperlink>
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.