Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 10th, 2007, 03:22 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default Gonna get by with a little help...

All,

was just thinking to myself there how much we all help indirectly with issues, problems and suggestions here on the forum and it occurred to me that the 'whole' is greater than the sum of the parts. Peter was desperately trying to get his site ready for alpha testing last week, max and kherr were facing similar issues and i have gone well past my 'go alpha' stage by almost 6 weeks (being in sw development, i know exactly how these things happen). So, it occurred to me that even tho' we're all busy beavering away on our own little 'domains', there exists the opportunity to 'co-opt' our skills to get the job done (i'm thinking a bit like the way the old frontiersmen all helped build each others barns).

to this end, it might be useful to somehow work out a quick 'n' dirty way to be able to pass over code that needs to be done in order to get the 'barn' functional. since the tbh framework is a known entity, this should be so straightfwd as to render it almost a no-brainer. i'll kick off by listing the basic bits that i need to be done in order for me to 'go alpha' (GA).

1. upload of image for profile/avatar pic, with resizing to set dimension (i have some crap code doing this at present, but not production standard)
2. generic control to upload multiple images (ajax or otherwise)

to be honest, that's about it for me. i do have masses to do once these bits are in place, but i've kinda mentally worked out how to do those and it should only take me a small %age of the project to put those in place. as for the other side of the coin, i can offer skills on the logic side of creating classes to fit in with the tbh structure, as well as the usual sideways thoughts on solutions to extant issues.

in reality, i know this thread may well die a death but i think it's a brilliant opportunity to both help each other out as well as expanding our knowledge and ultimately delivering our own projects a whole lot quicker....

jimi

http://www.originaltalent.com
__________________
jimi

http://www.originaltalent.com
  #2 (permalink)  
Old October 10th, 2007, 03:34 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Copenhagen, , Denmark.
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

jimi,

You probably found this, but I was looking for something similar (the image resizing), and came across this, which I ended up discarding due to my sincere dislike of javascript:

 1: <%@ Page Trace="False" Language="vb" aspcompat="false" debug="true" validateRequest="false"%>
  2: <%@ Import Namespace=System.Drawing %>
  3: <%@ Import Namespace=System.Drawing.Imaging %>
  4: <%@ Import Namespace=System %>
  5: <%@ Import Namespace=System.Web %>
  6: <SCRIPT LANGUAGE="VBScript" runat="server">
  7: const Lx = 200 ' max width for thumbnails
  8: const Ly = 240 ' max height for thumbnails
  9: const upload_dir = "/upload_resize_test/" ' directory to upload file
10: const upload_original = "sample" ' filename to save original as (suffix added by script)
11: const upload_thumb = "thumb" ' filename to save thumbnail as (suffix added by script)
12: const upload_max_size = 25 ' max size of the upload (KB) note: this doesn't override any server upload limits
13: dim fileExt ' used to store the file extension (saves finding it mulitple times)
14: dim newWidth, newHeight as integer ' new width/height for the thumbnail
15: dim l2 ' temp variable used when calculating new size
16: dim fileFld as HTTPPostedFile ' used to grab the file upload from the form
17: Dim originalimg As System.Drawing.Image ' used to hold the original image
18: dim msg ' display results
19: dim upload_ok as boolean ' did the upload work ?
20: </script>
21: <%
22: randomize() ' used to help the cache-busting on the preview images
23: upload_ok = false
24: if lcase(Request.ServerVariables("REQUEST_METHOD"))=" post" then
25: fileFld = request.files(0) ' get the first file uploaded from the form (note:- you can use this to itterate through more than one image)
26: if fileFld.ContentLength > upload_max_size * 1024 then
27: msg = "Sorry, the image must be less than " & upload_max_size & "Kb"
28: else
29: try
30: originalImg = System.Drawing.Image.FromStream(fileFld.InputStrea m)
31: ' work out the width/height for the thumbnail. Preserve aspect ratio and honour max width/height
32: ' Note: if the original is smaller than the thumbnail size it will be scaled up
33: If (originalImg.Width/Lx) > (originalImg.Width/Ly) Then
34: L2 = originalImg.Width
35: newWidth = Lx
36: newHeight = originalImg.Height * (Lx / L2)
37: if newHeight > Ly then
38: newWidth = newWidth * (Ly / newHeight)
39: newHeight = Ly
40: end if
41: Else
42: L2 = originalImg.Height
43: newHeight = Ly
44: newWidth = originalImg.Width * (Ly / L2)
45: if newWidth > Lx then
46: newHeight = newHeight * (Lx / newWidth)
47: newWidth = Lx
48: end if
49: End If
50:
51: Dim thumb As New Bitmap(newWidth, newHeight)
52:
53: 'Create a graphics object
54: Dim gr_dest As Graphics = Graphics.FromImage(thumb)
55:
56: ' just in case it's a transparent GIF force the bg to white
57: dim sb = new SolidBrush(System.Drawing.Color.White)
58: gr_dest.FillRectangle(sb, 0, 0, thumb.Width, thumb.Height)
59:
60: 'Re-draw the image to the specified height and width
61: gr_dest.DrawImage(originalImg, 0, 0, thumb.Width, thumb.Height)
62:
63: try
64: fileExt = System.IO.Path.GetExtension(fileFld.FileName).ToLo wer()
65: originalImg.save(Server.MapPath(upload_dir & upload_original & fileExt), originalImg.rawformat)
66: thumb.save(Server.MapPath(upload_dir & upload_thumb & fileExt), originalImg.rawformat)
67: msg = "Uploaded " & fileFld.FileName & " to " & Server.MapPath(upload_dir & upload_original & fileExt)
68: upload_ok = true
69: catch
70: msg = "Sorry, there was a problem saving the image."
71: end try
72: ' Housekeeping for the generated thumbnail
73: if not thumb is nothing then
74: thumb.Dispose()
75: thumb = nothing
76: end if
77: catch
78: msg = "Sorry, that was not an image we could process."
79: end try
80: end if
81:
82: ' House Keeping !
83: if not originalImg is nothing then
84: originalImg.Dispose()
85: originalImg = nothing
86: end if
87:
88: end if
89: %>
90: <html>
91: <head>
92: <title>ASP.NET File Upload and Resize Sample</title>
93: <META NAME="Description" CONTENT="ASP.NET File Upload and Resize Sample (Hybrid VB.NET)">
94: <META NAME="Keywords" CONTENT="ASP.NET, ASP, NET, VB, VBScript, Image, Upload, Resize, Thumbnail, Constrain, Filesize, File, Size, Free">
95: <META NAME="Copyright" CONTENT="Rufan-Redi Pty Ltd 2005">
96: <META NAME="Author" CONTENT="System developed by Jeremy at http://www.Rufan-Redi.com">
97: </head>
98: <body>
99:
100: <p><b>Hybrid ASP.NET File Upload and Resize Sample (VB.NET)</b>
101: <br>Upload and resize a GIP/JPG/PNG images, ensuring filesizes are optimum.</p>
102:
103: <form enctype="multipart/form-data" method="post" runat="server">
104: <table>
105: <tr><td>Select the file to upload:</td><td><input type="file" name="upload_file"></td></tr>
106: <tr><td colspan=2>Max upload size <%=upload_max_size%>Kb, gif/jpg/png only</td></tr>
107: <tr><td colspan=2><input type="submit" value="Upload"></td></tr>
108: </table>
109: </form>
110:
111: <%
112: if upload_ok then
113: %>
114: <table>
115: <tr>
116: <td valign=top><img src="<%=upload_dir & upload_original & fileExt & "?" & rnd()%>"></td>
117: <td valign=top><img src="<%=upload_dir & upload_thumb & fileExt & "?" & rnd()%>"></td>
118: </tr>
119: </table>
120: <%
121: else
122: response.write(msg)
123: end if
124: %>
125: </body>
126: </html>

I don't even remember where I found it, tbh.

As for multiple uploads, I just suggested to Maxxim in a different thread to just pre-code a certain amount of pre-designed boxes in order to cater to poll options. If you want multiple images, I'd suggest creating a control similar to the one we have as an upload, with 5 textboxes and 5 browse buttons, and a single upload button.

On the buttonclick, you just loop through textbox1 to 5, and do the same the upload control does now... I bet you can even just extend the existing upload control (which might be a tad more tricky, but it would be the more elegant solution).

HTH.

Peter

http://entropia-online.blogspot.com/
  #3 (permalink)  
Old October 10th, 2007, 03:42 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

peter - two issues with that example for me (and no disrespect to vb)

1. my site is c# based, so it'd have to be a very strong bit of watertight code that couldn't be otherwise done in c# to take me that way, altho' of course, i could 'translate'. also, the code that i have (but don't use) is probably tighter and less wordy. (i'll upload it later, [not at dev box right now])

2. i'd always always have a closed class to perform these duties, rather than page level code, so in a way, that's also a none starter.

i'm a fussy b*gger i know, and i suppose my 'barn' should have a few arcitects notes attached :) but do keep them coming... this is how we create the 'base' ground rules/understanding.

jimi

http://www.originaltalent.com
  #4 (permalink)  
Old October 10th, 2007, 04:40 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Copenhagen, , Denmark.
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

jimi - I totally share your non-page but site-wide approach. I noticed it was VB, but figured I'd just rewrite it (if neccessary). I had that, and some other suggestions on file uploading (including the one Maxxim offered). In the end, the tiny bit of code I posted proved to cover my needs :)

Peter

http://entropia-online.blogspot.com/
  #5 (permalink)  
Old October 10th, 2007, 04:52 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

peter - totally appreciated. the way i'd love to see this pan out would be where i (or you) the 'requirement-user' would define the requirement (in terms of language, interface and compliance (i.e. with 'site' standards)) and another 'provider-user' would pick up the ball, agree the specification (loosley) and go off and deliver the finished funtion on an agreed timescale (the 'requirement-user' could define this arbitary requirement upfront).

to this end, i'm not looking for ppeps to provide solutions in the message, rather go offline and agree 'terms' for delivery. of course, we'd all like to hear of the success stories, whereby this thread would provide the vehicle to do just this.

if there's enough interest, i/we could create a database/site with sloutions required and solutions delivered. this way, folk like me (needing the avatar upload function) could just download the solution plus any documentation. of course, therein lies the rub - how to encourage others with nice ideas to provide solutions if they don't require a 'co-op' solution in return.

jimi

http://www.originaltalent.com
  #6 (permalink)  
Old October 10th, 2007, 05:24 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

jimit, we are a programmers! we can't be faithful to one single language.

There was some times that i only found my hawsers in C#!
At beginning was hard but now I almost dominate the two languages!

I use this tool!
I translate all code with this tool, and past it to VS! Then I need to rectify one line or other but it's inevitable!

In my uploadPhoto in version 1 I did the following:
Add some properties to control with "enum"! So when you add a control in your aspx page you are forced to define this properties!
For example:
If controlType="Avatar" and widthLimit="100" my uploadControl will make a simple verification! First check if image is "gif/jpg" or "png" then save the image and then if widthLimit.lenght > 0 check if the with is lesser than this limit! Else send to the parentPage the text: "Images/InvalidAvatar.jpg" (I have that image on my server).

Peter don't like javascript but I can't live without it!
I add other property to my control!
ParentLabel = "lblPhotoUrl"
And after save the image if ParentLabel.length > 0 then run a simple javascript that insert on this label the right URLPath! Avoiding users to cut and past this string!

I have this on my Articles categories too!
When I want to add some Category it can be a principalCategory or a n-child category!
I made a Usercontrol only for categroiesTreeview and when a administrator add a new category select a minipopup made by css and when he makes the selection my javascript will insert on one disabled textBox the categoryID for the parent!

It's very nice but I spent several time with this! Javascript was a big help!

Don't discourage about the time we are spending on this!
You aren't experts! We are learning! TBH is fairway to be a site for our needs! The design is bad and the forums could be better (I don't call it "forums").
But the core is very good and with this application we have the rocks to make our building! And there are no buildings made on 2 days!

Besides! I made(almost) all this that I'm working now, in version 1.
Now I'm solving some problems that i saw in MY version 1!
BUT If it comforts you to know nobody(but Eric one time or other) helped me in ThePhile!
ThePhille don't had this little(but good) community to share doubts and knowledges...

My really frustration is because we don't that have help by expert skills frequently!
Marco is a Microsoft Programmer And certainly spent his last times to learning asp 3.5... And write the new book!
Between version 1 and 2 was the same!

You will see: When new book cames, some of us will have our sites working ok and look at the new book like (xiiii another few months of work trying to implement this new features) And the rest of us, maybe would abandon TBH and start all over again! And Marco will work on another new book "Asp.Net 2010" with no connection to the others!

I think this book should have 2 authors! one (Marco) with expert skills and other with another Internet WebSites Vision...

Sometimes I'm thinking:
Doesn't Marco have some curiosity to talk with a couple of faithful readers of the books he wrote and see the critics/suggestions to the new book?



  #7 (permalink)  
Old October 12th, 2007, 11:01 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: , , .
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kherrerab Send a message via Yahoo to kherrerab
Default

there was a mod for uploading images in the profile... i am not sure if it resize it but it works very goog on my site.

I said time ago that it would be great to share our own versions of thb websites.

  #8 (permalink)  
Old October 12th, 2007, 11:42 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by kherrerab
 there was a mod for uploading images in the profile... i am not sure if it resize it but it works very goog on my site.

I said time ago that it would be great to share our own versions of thb websites.

kherrerab - my idea is more 'helping' each other to get bits finished, rather than sharing the details of our own sites, which is after all part of our 'trade secrets' :). basically, i have the idea that we'd 'advertise' for someone to finish (for example) the uploads section and in return, i might do an extended forums section for them. we could have a basic little website to track who needed what and who ahd supplied what etc...

jimi

http://www.originaltalent.com
  #9 (permalink)  
Old October 12th, 2007, 11:52 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I think what Jimi is proposing to everyone is that the user base of TBH work similiarly to how sourceforge does (or other Open Source projects work for that matter).

Essentially you have a group of people working towards a common goal of perfecting or solving issues that TBH code base has and, in the end, everyone would win =]

You might want to say something to Jim, don't know if he would set you up a special thread here or something but it might be worth a shot =]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
  #10 (permalink)  
Old October 12th, 2007, 12:24 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by dparsons
 I think what Jimi is proposing to everyone is that the user base of TBH work similiarly to how sourceforge does (or other Open Source projects work for that matter).

Essentially you have a group of people working towards a common goal of perfecting or solving issues that TBH code base has and, in the end, everyone would win =]

You might want to say something to Jim, don't know if he would set you up a special thread here or something but it might be worth a shot =]
this might not be too bad an idea. where this would 'vary' from that model would be the fact that users would 'request' work to be done or users 'advertise' a feature that they would be willing to work on. basically in the end tho' if the same framework standards were observed, then each part added would be able to be put in place in a virgin install without compromise. however, as i noted in another thread (http://p2p.wrox.com/topic.asp?TOPIC_ID=65800) the framework as it stands, needs a minor change to allow it to be more modular. with these changes in place in a 'freash' install, we'd be more or less set.

anyway, thoughts on this in either this or the other thread.

jimi

http://www.originaltalent.com
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 01:35 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.