We help IT Professionals succeed at work.

FileUploader for Image inside user control, inside accordion,  inside update panel

Strychtur
Strychtur asked
on
315 Views
Last Modified: 2014-06-01
Hi All,

As the tittle says, I have a FileUpload control in a user control. When the user clicks the upload button I want to upload the image into an image control in the same user control. The user control resides in an accordion control which also resides in an update panel set as update mode = conditional and child triggers = false.
The problem I'm have is when the upload button is clicked inside the user control  causing a postback
the FileUpload control looses the selected file. FileUpLoad.FileName = "" inside the click event function of the button. Why and how do I get around it?
Comment
Watch Question

leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
>Why
By design?

>how do I get around it?
Try to set the OnClientClick attribute of the button :
OnClientClick="return false"

Open in new window

Author

Commented:
of the upload button?

Author

Commented:
When I do that the upload click event does not fire.
leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
>When I do that the upload click event does not fire.
So by design to upload the image your control need to do a postback

Go for an ASYNC FileUploader Control, for example : http://www.asp.net/ajax/ajaxcontroltoolkit/samples/asyncfileupload/asyncfileupload.aspx

Author

Commented:
Thanks I looked at the link.
But I'm still unsure and you provide example to upload Image using ASYNC FileUploader Control. I don't need to save until user clicks save button on main page outside user control. In which case I need to save to SQL 2005 db. Right now I just need to display the image. Is the image loaded into memory then the image control or is loaded from file to image control?

Author

Commented:
When I try I get an error file attached is invalid
Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
GlobaLevelProgrammer

Commented:
can you separate the two events independently of each other...

Author

Commented:
What do you mean? how?
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.