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

Amazon Server Control
by Jeffrey Schoolcraft

Here is cahing test code.

   filename=/students/jeffschoolcraft/displayamazonlink.aspx

<Test Script Below>


<%@ Register TagPrefix="myControls" Namespace="myControls" Assembly="AmazonLink" %>

<html>
<head><title>Amazon Link Server Control</title>
<body>

<myControls:AmazonLink
    strISBN="1590590171"
    strPartner="learnasp"
    intHeight=100    
    intWidth=75
    Runat="Server" />

<myControls:AmazonLink
    strISBN="0553380958"
    strPartner="learnasp"
    intHeight=100    
    intWidth=75
    Runat="Server" />
    
<myControls:AmazonLink
    strISBN="0553283685"
    strPartner="learnasp"
    intHeight=100    
    intWidth=75
    Runat="Server" />
    
<myControls:AmazonLink
    strISBN="0765341921"
    strPartner="learnasp"
    intHeight=100    
    intWidth=75
    Runat="Server" />
    
<myControls:AmazonLink
    strISBN="0399148701"
    strPartner="learnasp"
    intHeight=100    
    intWidth=75
    Runat="Server" />

</body>
</html>
Now for the server code source:

filename=/students/jeffschoolcraft/amazonlink.vb

Imports System
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace myControls

Public Class AmazonLink: Inherits Control

Public strISBN as String
Public strPartner as String
Public intHeight as Integer
Public intWidth as Integer

Protected Overrides Sub Render( objTextWriter As HtmlTextWriter )
    dim strAmazonURL as string = "http://www.amazon.com/exec/obidos/ISBN="
    dim objStrAmazonIMG as StringBuilder
    objStrAmazonIMG = New StringBuilder( "http://images.amazon.com/images/P/__ISBN__.01.MZZZZZZZ.jpg" )
    objStrAmazonIMG.Replace ( "__ISBN__", strISBN )

    with objTextWriter
        .AddAttribute( "href", strAmazonURL & strISBN & "/" & strPartner )
        .RenderBeginTag( "a" )
        .AddAttribute( "height", Unit.Pixel(intHeight).ToString() )
        .AddAttribute( "width", Unit.Pixel(intWidth).ToString() )
        .AddAttribute( "src", objStrAmazonIMG.ToString() )
        .RenderBeginTag( "img")
        .RenderEndTag()
        .RenderEndTag()
    end with
End Sub

End Class

End Namespace
Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site