Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 26th, 2006, 08:44 PM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default Wrox Photo Album Help

Ok, I'm quite the beginner here and most of the Wrox books I've purchased are step by steps that don't combine alot into an application such as in this book.

I am having a difficult time on understanding how to mix classes in (why you would) when you have sqldatasource's that can tie direct to databases--or have datasets, so I am trying to start with the Photo Album project and piece part it.

The first page aspx page (pg 223) is the photos.aspx page. What purpose does having "class=photoname" or "class=collection" in the <a> tag and <table align> tag? Are these classes? Why am I putting them here.

Kind Regards,
Rob

  #2 (permalink)  
Old September 27th, 2006, 01:58 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, they are classes, but not .NET classes like Product or Album.

They are CSS classes, are used to influence the presentation of a web page and refer to styles defined either inline or in a CSS file.

E.g.

<a href="#" class="MyLink">Click Me</a>

<style type="text/css">

.MyLink
{
  color: green;
}

</style>

In this case, the CSS class MyLink causes the link to become blue.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old September 27th, 2006, 07:52 AM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Makes sense---I'm just confused why there is other specific references in different syntax such as "CssClass=something" (Sorry at work and don't have the book).

So, in other words, there is "class= XXX" and "CssClass= XXX"??

THanks so much,
Rob

  #4 (permalink)  
Old September 27th, 2006, 08:18 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

CssClass is an ASP.NET server side control property that maps to the client side HTML class attribute.

So:

<asp:Image CssClass="SomeClass" ImageUrl="SomeImage.gif" runat="Server" />

ends up as :

<img src="SomeImage.gif" class="SomeClass" />

in the browser.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old September 27th, 2006, 08:57 AM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Ok...last question...I had my wife email me the source...so, am I correct in stating that the reason you have two different syntaxes (within one ASP Datalist control) is because the cssClass="item" references the ASP.Net control..however, the class="photoname" references an "a" tag (HTML). What threw me is you saying that class would reference html client code (rendered on page) and cssClass was for the control--however you see both used in the server code below. I assume for the reason I mentioned above?


Thank you,
Rob

<asp:DataList ID="DataList1" runat="Server" dataSourceID="SqlDataSource1"
    repeatColumns="6" repeatdirection="Horizontal" borderwidth="0px" cellpadding="3">
    <ItemStyle cssClass="item" />
    <ItemTemplate>
    <table align=left border="0" cellpadding="0" cellspacing="0">
         <tr>
            <td></td>
            <td nowrap width="100" valign="top">
            <a class="photoname" href="viewphoto.aspx?photoID=<%# Eval("photoID") %>">
            <%#GetName(Server.HtmlEncode(Eval("Name").ToString ()))%>
            </a>
            </td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <a href='viewphoto.aspx?photoID=<%# Eval("photoID") %>' >
                    <img class="viewphoto" src="upload/<%# Eval("filepath") %>"
                    height="95" width="95" alt='<%# Eval("description") %>' />
                </a>
            </td>
            <td></td>
        </tr>
    </table>
    </ItemTemplate>
</asp:DataList>

  #6 (permalink)  
Old September 27th, 2006, 12:55 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The DataList control you posted is a mix of server side and client side code. Or to be more exact: the server side DataList control contains an ItemTemplate that will be repeated for each item in your data source. This ItemTemplate in turn contains HTML that is send to the browser as is. That is, it's not transformed in any way.

That is why you see CssClass on the DataList (a server control that runs at the server and emits HTML to client, including a transformation from the CssClass property to the class attribute) and just class on the <a> and other tags in the ItemTemplate.

Just for fun, right-click one of those pages in the browser and choose View Source. You'll see that the DataList has been transformed to client side code (a <table> I think) and that the CssClass properties have been changed to class attributes.

Hope this clarifies things.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #7 (permalink)  
Old September 27th, 2006, 02:30 PM
Friend of Wrox
 
Join Date: Jul 2006
Location: olathe, ks, USA.
Posts: 238
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to rsearing
Default

Wonderful--thank you for your help!

Kind Regards,
Rob



Similar Threads
Thread Thread Starter Forum Replies Last Post
paging in photo album xperre BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 April 2nd, 2007 03:32 PM
Error posting photo to photo album abel714 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 10 February 5th, 2007 03:07 AM
Login failure - Wrox Photo Album devman BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 12 September 19th, 2006 10:20 AM
Photo Album Menus Tremmorkeep BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 August 15th, 2006 01:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.