p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   FileUpLoad to display selected graphic? (http://p2p.wrox.com/showthread.php?t=40617)

Ron Howerton March 31st, 2006 02:15 PM

FileUpLoad to display selected graphic?
I have a page that allows the user to browse to a folder, select a graphic, and upload it to our server. I'd like to display the selected graphic for the user prior to upload to ensure it's the graphic they really want. This seems like a common and simple enough task, but I have been unable to find a way to do it.

I'd like to automatically display the graphic when it's selected, but there appears to be no event on the FileUpLoad control that fires when a file has been selected. And I've tried adding a View Graphic button, which successfully displayed the selected graphic. But the FileUpLoad object loses the selected file name in the post back, so the user has to reselect it to upload it.

Is there a way to accomplish this in native ASP.NET (i.e. - WITHOUT using any third party products)?

rodmcleay April 4th, 2006 08:23 PM

Sure, handle the event on the client side so there is no need for postback
        FileUpload1.Attributes.Add("OnChange", "alert('Boo');" + Image1.UniqueID.Replace("$","_") + ".src=this.value;");

They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.

All times are GMT -4. The time now is 10:17 PM.

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