Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
 
Old June 8th, 2012, 01:32 PM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 14, Try-it-out 515-518

Hi,

At the end of this exercize, I sucessfully uploaded several images, but they are spread over the entire webpage. Is this correct? Should the page resize them to uniform size (or is that in a later step)?

I did use my own images, some of which were larger than the images supplied in the source.

thanks!
 
Old June 8th, 2012, 03:42 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

No, the images itself are not resized. However, they should be resized at the client using CSS (see page 510, step 13)

This is not ideal, as explained in the section A Few Notes about Perfomance on page 526. You can download the source for my Instant Results book (Chapter Greeting Cards) to see code that resizes images at the server.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 8th, 2012, 04:25 PM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am mainly just trying to figure out why my version isn't working. The .css was added to my frontend.master. I checked the markup of frontend.master, and the .css refrence is where it should be. (I verified that my frontend.master markup is the same as the source for chapter 14). Somehow the .css is not making it down to my ManagePhotoAlbum.aspx. i'm just not sure where the breakdown is.
thanks.
 
Old June 8th, 2012, 04:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you post the code for the CSS file and for the control that displays the images?

Also, try reloading with Ctrl+F5 or Ctrl+R; maybe it's a caching issue?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 8th, 2012, 04:59 PM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default My Code

Styles/Styles.css:
Code:
.ItemContainer
{
    width: 600px;
    list-style-type: none;
    clear: both;
}

.ItemContainer li
{
    height: 300px;
    width: 200px;
    float: left;
}

.itemContainer li image
{
    width: 180px;
    margin: 10px 20px 10px 0;
}
MasterPages/Frontend.Master:
Code:
<%@ Master Language="VB" CodeFile="Frontend.master.vb" Inherits="MasterPages_Frontend" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="../Styles/Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
(.......  the rest of this code is snipped  ..........................)
ManagePhotoAlbum.aspx:
Code:
<%@ Page Title="Manage Photo Album" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="ManagePhotoAlbum.aspx.vb" Inherits="ManagePhotoAlbum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" 
        DataSourceID="EntityDataSource1" InsertItemPosition="LastItem">
        <InsertItemTemplate>
            <li style="">
                Description:
                <asp:RequiredFieldValidator ID="reqDesc" ControlToValidate="DescriptionTextBox" runat="server" ErrorMessage="Enter A Description"></asp:RequiredFieldValidator>
                <asp:TextBox ID="DescriptionTextBox" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
                ToolTip:
                <asp:RequiredFieldValidator ID="reqTooltip" ControlToValidate="ToolTipTextBox" runat="server" ErrorMessage="Enter A Tool tip"></asp:RequiredFieldValidator>
                <asp:TextBox ID="ToolTipTextBox" runat="server" 
                    Text='<%# Bind("ToolTip") %>' />
                <br />
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <br />
                <asp:CustomValidator ID="CusValImage" runat="server" ErrorMessage="Select a valid .jpg file"></asp:CustomValidator>
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="False" />
            </li>
        </InsertItemTemplate>
        <ItemTemplate>
            <li style="">
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                <br />
                ToolTip:
                <asp:Label ID="ToolTipLabel" runat="server" Text='<%# Eval("ToolTip") %>' />
                <br />
                <asp:Image ID="ImageUrl" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' />
                <br />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" CausesValidation="False" />
            </li>
        </ItemTemplate>
        <LayoutTemplate>
            <ul class="ItemContainer">
                <li runat="server" id="itemPlaceholder" />
            </ul>
        </LayoutTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=PlanetWroxEntities" 
        DefaultContainerName="PlanetWroxEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EntitySetName="Pictures" 
        EntityTypeFilter="" Select="" Where="it.PhotoAlbumId = @photoAlbumId">
        <WhereParameters>
            <asp:QueryStringParameter Name="PhotoAlbumId" QueryStringField="PhotoAlbumId" 
                Type="Int32" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cpClientScript" Runat="Server">
</asp:Content>
I'm thinking the .vb code isn't necessary, but i can post that too, if you need it.
Thanks again. I really appreciate you and this forum.
 
Old June 8th, 2012, 05:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this:

Code:
 
.itemContainer li image
{
    width: 180px;
    margin: 10px 20px 10px 0;
}
You have itemContainer with a lower case i. In all other places, ItemContainer is written with an upper case I. Since CSS is case-sensitive, .itemContainer li image is never applied.

On top of that, it should be img, not image. So the full selector should be like this:
Code:
 
.ItemContainer li img
{
  width: 180px;
  margin: 10px 20px 10px 0;
}
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 8th, 2012, 05:20 PM
Authorized User
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sorry

I should have caught that. I knew it had to be the style sheet, I just had it in my head that it wasn't being applied because i had missed something. I went over everything else trying to find the code i missed. Never occured to me that the problem was the style sheet the whole time.

It's hard to teach this old mainframe programmer an up-to-date language.

Thank you so much for your help. I really do appreciate it. I'll look harder before I post next time.
 
Old June 8th, 2012, 05:26 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I'll look harder before I post next time.
Don't worry about that. It's sometimes useful to have a fresh pair of eyes to look at a problem....

Quote:
It's hard to teach this old mainframe programmer an up-to-date language
;-) Good luck....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
ch: 14, Try it out pg: 515 binaryspirit BOOK: Beginning ASP.NET 4 : in C# and VB 6 May 4th, 2012 12:49 PM
Chapter 14, first 'Try It Out' alharlow BOOK: Beginning ASP.NET 4 : in C# and VB 5 March 18th, 2011 05:00 AM
Chapter14 Try it Out Page 515 tostermann BOOK: Beginning ASP.NET 4 : in C# and VB 7 December 2nd, 2010 03:59 AM
chapter 14 vthunder70 BOOK: Beginning ASP.NET 2.0 and Databases 2 October 3rd, 2007 02:11 PM
Chapter 14 JonG BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 March 21st, 2006 10:04 PM





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