Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Web Pages with WebMatrix
This is the forum to discuss the Wrox book Beginning ASP.NET Web Pages with WebMatrix by Mike Brind, Imar Spaanjaars ; ISBN: 978-1-1180-5048-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Web Pages with WebMatrix 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 January 17th, 2012, 12:44 PM
Authorized User
 
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default Chapter 8:Resizing Uploaded images.

Hi,

I am having issues with my gallery. I have upload 3 or 4 images to my upload folder, but when I run the gallery.cshtml page i only get 1 image to display. Also, when I click on the thumbnail the Fancybox doesn't seem to work I get a new page with the larger image. Please help, Thanks

This is the message I get from firebug in Firefox:

If <script> tags have a "type" attribute, it should equal "text/javascript" or "application/javascript". Also scripts must be parsable (syntactically correct).

I see text/javascript in the appropriate places.
Code:
Code:
@{
    var folderName="";
    var path="";
    var files=new List<string>();
    if(Request.Cookies["folder"] != null){
        folderName =Request.Cookies["folder"].Value;
        path=Path.Combine(Server.MapPath("/Uploads/"), folderName);
        foreach(var file in Directory.GetFiles(path)){
            if(Path.GetFileName(file).Contains("_thumb_")){
                files.Add(Path.GetFileName(file));
            }
        }
    }
}
<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Gallery</title>
        
        <link rel="stylesheet" href="@Href("~/Content/tinycarousel.css")" type="text/css" />
        <link rel="stylesheet" href="@Href("~/Content/jquery.fancybox-1.3.4.css")" type="text/css" />
        <script type="text/javascript" src="@Href("~/Scripts/jquery-1.7.1.min.js")"></script>
        <script type="text/javascript" src="@Href("~/Scripts/jquery.tinycarousel.min.js")"></script>
        <script type="text/javascript" src="@Href("~/Scripts/jquery.fancybox-1.3.4.pack.js")"></script>
        <script type="text/javascipt">
            $(document).ready(function(){
                $('#slider-code').tinycarousel();
                $('.thumb').fancybox();
            });
        </script>
    </head>
    <body>
       <h3>Gallery</h3>
        <div id="slider-code">
            <a class="buttons prev" href="#">left</a>
            <div class="viewport">
                <ul class="overview">
                    @foreach(var file in files){
                        <li>
                            <a class="thumb" href="Uploads/@folderName/@file.Replace("_thumb", "")">
                            <img src="Uploads/@folderName/@file" alt=""/>
                            </a>
                        </li>
                    }
                </ul>
        </div>
        <a class="buttons next" href="#">right</a>
        </div>
    </body>
</html>
 
Old January 18th, 2012, 08:52 AM
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:
 
<script type="text/javascipt">
You have javascipt instead of javascript with an r....

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 January 18th, 2012, 09:56 AM
Authorized User
 
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Thanks Imar.

I have another issue I uploaded other pictures into the upload folder but when I run the gallery only 1 picture is displaying and not any others. I think its because I need to delete the cookie and then run the page. If that's so how can I programatically delete the cookie and have new one set so its not manually done?

Thanks.
 
Old January 18th, 2012, 10:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

To delete a cookie, you can set the expiry date to a date in the past (using something like DateTime.Now.AddYears(-1) for example. Then the browser will clean it up for you.

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!
The Following User Says Thank You to Imar For This Useful Post:
hozdaman (January 18th, 2012)
 
Old October 8th, 2012, 12:57 PM
Authorized User
 
Join Date: Feb 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Image Gallery chapter 8 not working

I'm having the same problem with the image gallery. I only see one image and the arrow buttons don't work.. in other words they don't slide to the other images in either direction (left or right).

I deleted the cookies already and started over.. can't find the fix... can you help?

thanks
p.s. tried IE9 and Firefox... no luck
 
Old October 8th, 2012, 02:47 PM
Wrox Author
 
Join Date: Dec 2011
Posts: 57
Thanks: 1
Thanked 19 Times in 19 Posts
Default

Download the code samples for Chapter 8 and see if the final one runs ok. If it does (which it should) compare the code there to what you have for typos etc.





Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading/resizing (transparant) images in C# smiter C# 1 February 19th, 2007 08:53 PM
Resizing Images san123 ASP.NET 1.0 and 1.1 Basics 2 April 26th, 2006 02:51 PM
Resizing images according to paper size Taxidriver Crystal Reports 3 March 28th, 2006 06:08 AM
GDI+ - Issue Resizing images Hubman VS.NET 2002/2003 2 April 16th, 2004 08:11 PM
Resizing Images From a Database mayhew3 Pro PHP 1 March 3rd, 2004 07:19 PM





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