 |
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
|
|
|
|
|

September 25th, 2015, 08:49 AM
|
|
Registered User
|
|
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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..
|
|

September 28th, 2015, 03:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

September 29th, 2015, 05:40 PM
|
|
Registered User
|
|
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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 ??
|
|

October 4th, 2015, 11:25 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

October 5th, 2015, 03:32 PM
|
|
Registered User
|
|
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Paging Problem solve
Thanks a lot for your reply I have been able to solve the problem.
|
|

October 5th, 2015, 05:26 PM
|
|
Registered User
|
|
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 6th, 2015, 03:09 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
Last edited by Imar; October 7th, 2015 at 03:47 AM..
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

October 6th, 2015, 02:14 PM
|
|
Registered User
|
|
Join Date: Sep 2015
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Thanks
Thanks for the reply
|
|
 |
|