Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : 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 September 25th, 2015, 08:49 AM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Post How to create a thumbnail

At the end of chapter 14 you said something about performance issues. You said we should create a thumbnail at the server before previewing it in the browser. And you referred as to read instant Asp.net 2.0 under the greeting cards chapter to learn how to create a thumbnail. But unfortunately for me the code was in visual basic and not c-sharp. So I was wondering if you could help me to create a thumbnail when the user uploads an image at the server before displaying it in the browser.
This is the code to upload an image to the server.

Code:
    protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        /*
        Gets the querystring from the page and insert it into the picture table
        under the PhotoAlbumId  column
        */
        int photoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));
        Picture myPicture = (Picture)e.Entity;
        myPicture.PhotoAlbumId = photoAlbumId;

        /*
        Uploading the picture to the file server and save it reference to the 
        database under the imageUrl column.
        Also performing some validations

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

    
    }

Last edited by Newton111; September 25th, 2015 at 09:02 AM..
 
Old September 28th, 2015, 03:30 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

Hi there,

It's a bit too much to write the entire implementation for you. May I recommend http://converter.telerik.com/ to convert form VB to C#? Then feel free to post follow up questions here. Or better, in the General ASP.NET category here: http://p2p.wrox.com/asp-net-4-5-709/ since it's not book specific.

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:
Newton111 (September 29th, 2015)
 
Old September 29th, 2015, 05:40 PM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Using the List view control

Thanks and I have been able to solve the issue by convert the VB to C# using the provided link.
But now how can I use Listview and Data Pager controls together with Linq's Skip and Take methods to limit the amount of data that is sent to the browser ??
 
Old October 4th, 2015, 11:25 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

Hi there,

Search Google for ASP.NET Model Binding which will show you how to use LINQ and the data controls. My 4.5.1. book shows how this works too.

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:
Newton111 (October 5th, 2015)
 
Old October 5th, 2015, 03:32 PM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Paging Problem solve

Thanks a lot for your reply I have been able to solve the problem.
 
Old October 5th, 2015, 05:26 PM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default How can you implement a search field in your aspx website?

I was wondering if you could give me some ideas on how to search items in your database and send the results to an aspx page. For instance when you use the search textbox in www.wrox.com to search an item, after the item is found, it sends the results to the search page.
Like this
http://www.wrox.com/WileyCDA/Section...tml?query=c%23
 
Old October 6th, 2015, 03:09 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

Hi there,

It's better to start a new thread for new topics. Your new question is unrelated to thumbnails so it would have been better of as a separate subject.

That said, here's what I would do:

1. Add a text box and button to your page. On click of the button, redirect the user to the search results with the search terms in the Query String. Something like this:

Response.Redirect(string.Format("Search.aspx?terms ={0}"), SearchBox.Text);

2. In Search.aspx, search the database using the passed in query string terms. You can either hook up a SqlDataSource control with a query string parameter, or use something like LINQ and model binding to get the data and show it on the page.

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!

Last edited by Imar; October 7th, 2015 at 03:47 AM..
The Following User Says Thank You to Imar For This Useful Post:
Newton111 (October 6th, 2015)
 
Old October 6th, 2015, 02:14 PM
Registered User
Points: 24, Level: 1
Points: 24, Level: 1 Points: 24, Level: 1 Points: 24, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Thanks

Thanks for the reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
Create a thumbnail image of a Word doc SQLScott Pro Visual Basic 2005 4 February 6th, 2013 08:54 AM
create thumbnail in c# naveen sharma .NET Framework 3.5 0 September 22nd, 2010 05:34 AM
Create Image Thumbnail echovue Access VBA 1 June 30th, 2006 07:31 AM
Plz help me to Create image thumbnail shahidzafar Classic ASP Professional 4 September 23rd, 2003 04:32 PM





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