How to programmatically create UpdatePanel with FileUpload?

  • Thread starter Thread starter Bogdan
  • Start date Start date
B

Bogdan

Hi,

I need to programmatically create UpdatePanel with FileUpload control. The
problem is that for FileUpload control to function properly in UpdatePanel
it needs a post back trigger. Unfortunately, according to docs, you cannot
programmatically add triggers to UpdatePanel.
Does that mean that it is impossible to programmatically create UpdatePanels
with FileUpload controls?

Thanks,
Bogdan
 
a fileupload will not work in an update panel unless it does a full
postback (javascript cannot access a file on the disk). you csn have an
update panel render a fileupload, but you need it to do a form.submit()
from javascript (and be sure the form type is correct) or call the click
event of a button outside the panel.

-- bruce (sqlwork.com)
 
Bruce,

Thanks for the reply.

If I got it right, the full postback can be achieved by adding a trigger to
an UpdatePanel. Am I right? But, unfortunately, it seems that adding a
trigger to UpdatePanel can only be done declaratively and not
programmatically.

I have a page with one or more small areas dedicated to uploading of files.
Each area initially displays choices and then - based on a choice - either a
file upload control or other controls (listbox, editbox, etc.). It seems
like UpdatePanel would be an ideal choice for the area. I don't think I'd
have a problem with implementing it declaratively. When a FileUpload
control is shown I'd simply assign a postback trigger to Upload button that
I place beside the file upload control. That it turn would result in a full
postback.

But, I can't assign a trigger programmatically. Any ideas?

Thanks again,
Bogdan
 
Back
Top