Saturday, March 24, 2012

AJAX and the Upload Control - My Solution

Hello everyone,

I thought I should post this solution since I had a hard time finding any solution on this forum.

If you have an<asp:FileUpload control in an AJAX you need to add a section like:

<Triggers>
<asp:PostBackTriggerControlID="myUploadSubmitButton"/>
</Triggers>

This will add a postback for the button. If the upload control is hidden and visable by a button in the UpdatePanel you will need to add a postback trigger for that too.

This works for me without any issues.

- Chris

P.S. Visit wiki.cdyne.com for some more cool programming things!

Thanks for this solution. But full page update will occur in this case.

The Postback Trigger allows for the file upload to work correctly but then it breaks all the rest of my other AJAX update panels (calendars popups, etc.) that are on the page.

Using ASP.NET AJAX Beta 2.


Hey cchenoweth,

I am having trouble with FileUpload inside UpdatePanel, there is no data when a button click happens. Where is this PostBackTrigger control? Is this in Atlas toolkit? can you post where to put this and where to get this control. Thanks.

den2005


Hey Chris,

I have worked it out it's working.. Tahnsk for this tip very helpful.

Thanks again.

Dennis


Hey Chris,

I have worked it out it's working.. Thanks for this tip very helpful.

Thanks again.

Dennis


den2005:

Hey cchenoweth,

I am having trouble with FileUpload inside UpdatePanel, there is no data when a button click happens. Where is this PostBackTrigger control? Is this in Atlas toolkit? can you post where to put this and where to get this control. Thanks.

den2005

come on then den2005 dish the info ..... where is it then;)??

I'm having the same problems but i just canna find this so called PostBackTrigger - within the <trigger> section all i get is <atlas:ControlEventTrigger> and <atlas:ControlValueTrigger>

now i think i've got the latest version etc... is there a namespace i should be using to access this r??

(yes i'm very new to all this..8-)]

ta in advance


Sprayball,

Just as Chris mentioned, you need to put this on after the

<asp:UpdatePanel

but before the

<

ContentTemplate>and add in your load event or before you used the buttonclick, say id of your script manager is sm,

sm.RegisterPostBackControl(myUploadSubmitButton)

<Triggers>
<asp:PostBackTriggerControlID="myUploadSubmitButton"/>
</Triggers>


Hi !

I tried your solutions but i think my case is a little bit more complicated : my FileUpload Control is in an edittemplate of a gridview, in an updatepanel.

So my first question is : how can you define the ID of the Upload Submit Button ? I have only access to the ID of the FileUpload ...

and my second question is : when do i have to register the upload submit button as a PostbackControl ? during the rowdatabinding of the gridview ? during gridview updating ?

Thank you very much in advance for your help because for now it works, but without update panel (i get nothing in the postedfile property of the fileupload with the updatepanel) !

Axel


Is there a way to do the same thing but with JavaScript (on client side)?

koistya,

It is possible using hidden field and setting this control value after getting the value of the FileUpload control...Then you can get the value of this hidden field control at server side...

This works...Try it...Smile


HI,

Is there a way to make FileUpload control work with partial page update?

<asp:PostBackTrigger> makes a full page refresh and resets all my ajax dragpanels to their original position.

I tried AsyncPostBackTrigger, with the submit button outside the update panel, and it doesn't function well (doesn't upload the file).



Thanks in advance!

No comments:

Post a Comment