I am using the FileUpload control inside an Ajax updatepanel. I also am using a post-back trigger to force the upload button to postback. However, when I click on the upload button for the first time, FileUpload.PostedFile = null. Yet, it works fine after the first time . I don't know what's the error here ?
Asked
Active
Viewed 743 times
1
-
1possible dupe http://stackoverflow.com/questions/2264541/fileupload-and-updatepanel-scriptmanager-registerpostbackcontrol-works-the-secon – MikeM Aug 18 '11 at 03:32
-
Either your `UpdatePanel` OR the `FileUpload` control are not visible at the time of PreRendering of the page. See: [this](http://stackoverflow.com/a/11576376/365188) and [this](http://stackoverflow.com/a/34338443/365188). – Ozair Kafray Jan 12 '16 at 12:43
1 Answers
0
If you are going to use ajax, I highly recommend using the async file uploader in the Ajax Control Toolkit. The update panel and the standard ASP.NET file upload control do not play nicely with one another. The AJAX Control toolkit version of the control should solve most of your problems. However, for your immediate problem, make sure the form tag has multipart specified.

Jonathan Henson
- 8,076
- 3
- 28
- 52
-
thanks for your reply, how can i make sure that the form tag has multipart specified – Mounir Aug 18 '11 at 21:05
-
-
i have imagebutton in datalist and make the same problem when click,are you know what can i do ?i use your solution but it doesn't help in this case – Mounir Aug 19 '11 at 02:42
-
you should only need a postback trigger. the problem, of course is that you can't do a postback trigger for an indefinite number of items with dynamically assigned ids. You will need to add the triggers in the itemdatabound method for the datalist. You can grab the control and create the trigger there for each row. – Jonathan Henson Aug 19 '11 at 03:45
-
i do that in itemdataboun event handler but the problem is still AsyncPostBackTrigger Trigger = new AsyncPostBackTrigger(); ImageButton Btn = (ImageButton)e.Item.FindControl("ImgBtnMail"); Trigger.ControlID = Btn.UniqueID.ToString(); Trigger.EventName = "Click"; up1.Triggers.Add(Trigger); – Mounir Aug 19 '11 at 15:56
-
-
when i use PostBackTrigger, i got the message ( A control with ID 'ctl00_ContentPlaceHolder1_DLAds_ctl00_ImgBtnMail' could not be found for the trigger in UpdatePanel 'up1'.) – Mounir Aug 19 '11 at 21:04
-
1st, an image button shouldn't need a postback trigger to begin with, 2nd this should be a separate question. – Jonathan Henson Aug 19 '11 at 21:28