Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 February 18th, 2010, 07:44 PM
Authorized User
 
Join Date: Nov 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to Ali Ezz
Default How could I resize the images in the Listview to a bigger size ?

Imar,

I've got a small problem, How could I resize the image in the listview to a bigger size ? And I need your help to tell me which changes should I make in the code ?

My code is this:
Code:
<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="LinqDataSource1" InsertItemPosition="LastItem" 
        oniteminserting="ListView1_ItemInserting">
        <ItemTemplate>
            <li style="">
            
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Bind("Description") %>' />
                
                Tooltip:
                <asp:Label ID="TooltipLabel" runat="server" Text='<%# Bind("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>
        
        
        <InsertItemTemplate>
            <li style="">Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" TextMode="MultiLine" Text='<%# Bind("Description") %>' />
                
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="DescriptionTextBox" runat="server" ErrorMessage="Please enter a description"></asp:RequiredFieldValidator>
                Tooltip:
                <asp:TextBox ID="TooltipTextBox" runat="server" Text='<%# Bind("Tooltip") %>' />
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TooltipTextBox" runat="server" ErrorMessage="Please enter a tooltip"></asp:RequiredFieldValidator>
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <br />
                <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please select a valid .jpg file"></asp:CustomValidator>
                
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="false"/>
            </li>
        </InsertItemTemplate>
        <LayoutTemplate>
            <ul class="itemContainer">
                <li ID="itemPlaceholder" runat="server" />
                </ul>        
        </LayoutTemplate>
    
        </asp:ListView>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
            ContextTypeName="PlanetWroxDataContext" EnableDelete="True" EnableInsert="True" 
            TableName="Pictures" Where="PhotoAlbumId == @PhotoAlbumId" 
            oninserting="LinqDataSource1_Inserting">
            <WhereParameters>
                <asp:QueryStringParameter DefaultValue="-1" Name="PhotoAlbumId" 
                    QueryStringField="PhotoAlbumId" Type="Int32" />
            </WhereParameters>
        </asp:LinqDataSource>
</asp:Content>
The .cs is:
Code:
protected void Page_Load(object sender, EventArgs e)
            {
                int photoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));
                using (PlanetWroxDataContext myDatabaseContext = new PlanetWroxDataContext())
                    {
                        string photoAlbumOwner = (from p in myDatabaseContext.PhotoAlbums
                        where p.Id == photoAlbumId
                        select p.UserName).Single();
                        if (User.Identity.Name != photoAlbumOwner && !User.IsInRole("Managers"))
                            {
                                Response.Redirect("~/");
                            }
                    }
            }

        protected void LinqDataSource1_Inserting(object sender, LinqDataSourceInsertEventArgs e)
            {
                ////////
                Picture myPicture = (Picture)e.NewObject;
                myPicture.PhotoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));

                ///////
                FileUpload FileUpload1 = (FileUpload)ListView1.InsertItem.FindControl("FileUpload1");
                string virtualFolder = "~/GigPics/";
                string physicalFolder = Server.MapPath(virtualFolder);
                string fileName = Guid.NewGuid().ToString();
                string extension = System.IO.Path.GetExtension(FileUpload1.FileName);
                FileUpload1.SaveAs(System.IO.Path.Combine(physicalFolder, fileName + extension));
                myPicture.ImageUrl = virtualFolder + fileName + extension;

            }

        protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
            {
                FileUpload FileUpload1 = (FileUpload)ListView1.InsertItem.FindControl("FileUpload1");
                if (!FileUpload1.HasFile || !FileUpload1.FileName.ToLower().EndsWith(".jpg"))
                    {
                        CustomValidator CustomValidator1 = (CustomValidator)ListView1.InsertItem.FindControl("CustomValidator1");
                        CustomValidator1.IsValid = false;
                        e.Cancel = true;
                    }      
            }

Just need you to guide me to which changes should be made to the code ?
__________________
aliezz
 
Old February 18th, 2010, 10:18 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,

The image size is defined in the CSS file, as explained in the Try It Out exercise.

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 February 19th, 2010, 03:55 PM
Authorized User
 
Join Date: Nov 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to Ali Ezz
Default

Imar,

I tried to resize the image to a bigger size, but I failed here's my code + the above one;

I undo the changes I made, so just set ANY bigger size to the images by your own code, so that I could try it ..

Code:
.itemContainer
{
  width: 600px;
  list-style-type: none;
}

.itemContainer li
{
  height: 280px;
  width: 200px;
  float: left;
}

.itemContainer li img
{
  width: 180px;
  margin: 10px 20px 10px 0;
}
__________________
aliezz

Last edited by Ali Ezz; February 19th, 2010 at 04:01 PM..
 
Old February 22nd, 2010, 06:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you mean, it failed? Did they explode? Did they turn green? Did they completely disappear? Did they not resize at all? What exactly did you change where and how? Are you sure the browser picked up the right style sheet and changes? Did you try resetting the width of the image? To make sure it's related to the width, did you try to make other changes and see of they had any effect?

In other words, show me a problem and I can ask a million questions. Show me a crystal clear problem description including detailed steps of your own actions, and I'll give you one answer.....

width: 250px;

Should do the trick, theoretically,

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
How to make spacing between the Description of two images in ListView ? Ali Ezz BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 February 18th, 2010 10:15 PM
ch.2- cant upload a file no bigger than 52 MB?? cluce BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 April 30th, 2008 09:08 AM
Upload and Resize Images raaj Beginning PHP 2 June 30th, 2007 04:49 AM
save images in size .75 X .75 infotech VB How-To 2 May 11th, 2007 05:54 PM
Resizing images according to paper size Taxidriver Crystal Reports 3 March 28th, 2006 06:08 AM





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