locked
Using FileUpload Control inside ASP.Net AJAX UpdatePanel Control RRS feed

  • Question

  • User-2070085044 posted

    I have tried below both coding part.   My requirement is to add images to griedview lines. So when I am clicking on an item in grid, it will popup a div   containing fileuplod control. 

    I need to update this without refreshing page.  so when I am using  <asp:AsyncPostBackTrigger ControlID="Btn_UploadImage" EventName="Click" />  I am not getting  "hasfile" or file name.  

    but if I use second option -- <asp:PostBackTrigger ControlID="Btn_UploadImage" />  working properly,   BUT PAGE REFRESHING / POSTBACK IS WORKING.   I need to do this without refreshing the page. 

    <Triggers> <asp:AsyncPostBackTrigger ControlID="Btn_UploadImage" EventName="Click" />  </Triggers>

    -----------------------------

    <Triggers> <asp:PostBackTrigger ControlID="Btn_UploadImage" /> </Triggers>

    regards,

    Sajeesh

    Wednesday, June 7, 2017 8:14 AM

All replies

  • User-1716253493 posted

    AFAIK FU need full postback,

    Try using below control

    http://www.ajaxcontroltoolkit.net/AsyncFileUpload/AsyncFileUpload.aspx

    Wednesday, June 7, 2017 8:26 AM
  • User-2070085044 posted

    thanks for your reply.

    I have verified this.  My fileupload control is in a DIV  (which is display:none mode) inside UPDATE PANEL, this DIV only display at the time of clicking gridlink button.  

    so normal asp.net fileupload is supporting, and this is working with a BUTTON click  if I added  <asp:PostBackTrigger ControlID="Btn_UploadImage" /> in TRIGGER section. 

    but in this case, full page is refreshing.   I need to do this without refreshing whole page.  So I placed <asp:AsyncPostBackTrigger ControlID="Btn_UploadImage" EventName="Click" /> in this case BUTTON click is working without refreshing whole page, But fileupload control showing value null. 

    regards, 

    sajeesh 

    Wednesday, June 7, 2017 10:20 AM
  • User-1838255255 posted

    Hi sajeesh,

    According to your description, as far as I know, if you want to use fileupload inside updatepanel, I think it needs a full postback. You could add a breakpoint in the click event, check if get the file. For more details, please check the following document:

    Using FileUpload Control inside ASP.Net AJAX UpdatePanel Control:

    https://www.aspsnippets.com/Articles/Using-FileUpload-Control-inside-ASP.Net-AJAX-UpdatePanel-Control.aspx 

    Best Regards,

    Eric Du

    Wednesday, June 14, 2017 2:00 AM
  • User-1716253493 posted

    But fileupload control showing value null. 

    It's everyone issue for upload control inside ajax panel i guess.

    - option1 use full postback

    - option2 dont use fileupload control, you can use fileupload control from ajaxcontroltoolkit

    Wednesday, June 14, 2017 2:12 AM
  • User-2070085044 posted

    Eric Du, 

    First of all thanks for your reply. 

    I have read the details in the link, and which I have already read and tried.  while trying  Button with AsyncPostBackTrigger  Hasfile returns null., but if we are using PostBackTrigger  file uploading is working properly.  But issue is  why I placed this popup div inside update panel means, I need to avoid page refreshing / postback function.

    Scenario is,   I have a grid with number of line items.  Number of lines may be 1 - 100 or 200 or more,   Users need to add Images against each line item in this grid.  So I have placed an image control in one column, and ItemNumber filed set it as a link button.   So when I click on 10 line, will popup DIV,  shows the Line item number and description on there, and placed this Fileupload control and Upload button in this DIV.  so popup DIV is properly working without postback as I used Jquery to popup the DIV,.   and I can select the file also without page refresh.    I need to update the Grid with the uploaded image at the time of UploadButton Click.     So if I am giving PostBackTrigger  here, page will refresh and move to top area.   In this case, if users entering 20th, or 30th lines page will refresh and they need to drag to down again to add image for next line item. This will be a tedious practice if we have more items in Grid.    

    Hope you have understand my scenario.  Now after continues research for this, I could upload files without postback using Jquery and Generic Handler page. But still I couldn't bind the grid after file upload as we cannot call codebehind method from Jquery. we can call static method, but in this case page controls are not accessible. 

    Regards, 

    Sajeesh 

    Wednesday, June 14, 2017 1:22 PM