Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 March 22nd, 2006, 08:10 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to update asp:image control

I have the following code,
============
<input id="txtUpload" type="file" runat="server" />
<input id="btnPreview" type="button" value="Preview"
          OnServerClick="Preview" runat="server" /><br />
<asp:Label id="lblMessage" runat="server" /></p><br />
<asp:Image id="myImage" ImageUrl="c:\abc.png" runat="server" />
=========
  Sub Preview(s as object, e as eventargs)
    dim strFile as string
    strFile=txtupload.postedfile.filename
    myImage.imageUrl=strFile
    strFile = strFile
  End Sub
=========

I want to select an image file using the input file control, as soon as the file is selected, I want it to view it in the Image Control. How can I do it ? Now by clicking the button control and calling the sub preview I am able to view the file but then file control looses the focus on the file. Is there any attribute of the File Control or Image Control for showing the image file in the Image control ?

:(

 
Old March 22nd, 2006, 09:03 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I don't understand your problem? You are trying to preview an image in the image control but what do you mean that the file control is losing its focus? Do you mean that once you click the button the file upload dialog box is empty? If that is the case, you are out of luck unless you create a custom server control that implements the HtmlInputBox and overrides it's text property because the file controls text property is read only, e.g. you can't pragmatically assign values to it.

The only thing that I can think of is to use AJAX functionality to upload the image and return it to the user but the question i have is, are you actually uploading the file to the server or you just want to show the user a preview of an image that they are uploading?

"The one language all programmers understand is profanity."
 
Old March 23rd, 2006, 03:03 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I want to show the user the file he is going to upload..Just to make sure he is going to upload the correct file.

When I click the button to preview, the fileupload Text box (txtUpload) is emptying, but showing the file in the Image control. The problem is because the txtupload.postedfile.filename is cleared, unless the user select the file again, while saving, the file name will not be saved as well as the file won't be upload. The user in this part of the world are reluctant to select the file again.

So I want to show the file as soon as he select it to the txtUpload file control.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
set image on <asp:Image> stored in DataBase myself.panku ASP.NET 2.0 Professional 1 August 11th, 2008 10:41 AM
CHAPTER 7 - UPDATE an Image dutraveller BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 March 20th, 2008 12:27 PM
Image -- Insert/Update/Delete in sql2000 !!! dagad ASP.NET 2.0 Basics 0 October 27th, 2006 08:25 AM
Dynamic Image Update aymawadi ADO.NET 1 April 10th, 2005 04:53 PM





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