We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

On post to SaveDefault IEnumerable is null

I'm using the UploadBox control and using the example code to implement the SaveDefault method, e.g.:

public ActionResult SaveDefault(IEnumerable<HttpPostedFileBase> UploadDefault)
        {
            foreach (var file in UploadDefault)
            {
         ...
        }
     ...
}

The problem is that UploadDefault is null... If I start from a blank project or run a sample project it works correctly. 
I first came across the problem in some older code - I added in SyncFusion to the project and on running the UploadDefault was null. I assumed it was just some code clash. or some hang over of the way I had implemented the MVC code.
I can actually see that the client code is returning (what appears to be) to the server an HTML response with the file encoded - so does not appear to be a client issue but server side processing

However, I started another new project and now that project is now returning null. I've checked all the things I can - has anyone else come across this? Have I missed something simple (e.g. jQuery version clash, incompatiblity with .NET 4.5.1)?

Thanks,


3 Replies

PP Prasanth Palani Syncfusion Team August 14, 2015 08:32 AM

Hi Aubyn,
 Thanks for using Syncfusion products,
In MVC model binding, we specify the name of the component in the controller to get the values. Similarly here you need to specify the name of the uploadbox component in the controller. We maintain the “id” of the component as the “name”. So please specify the “id” of the component in the controller as shown below and you will get the file details in the IEnumerable object.

View


@Html.EJ().Uploadbox("FileUpload").SaveUrl(@Url.Action("SaveDefault")).RemoveUrl(@Url.Action("RemoveDefault"))



Controller


public ActionResult SaveDefault(IEnumerable<HttpPostedFileBase> FileUpload)

        {

            foreach (var file in FileUpload)



We have prepared simple sample to showcase your requirement, please check it,
http://www.syncfusion.com/downloads/support/directtrac/119920/UploadBoxsyn114344373.zip
If still you face any difficulties please revert back the provided sample based on your application to showcase the issue that you are facing and we will be happy to help you.
To know about the list of properties, methods and events supported by any JS component, go to the online help link for JS (http://helpjs.syncfusion.com/js/overview) and click on the “API reference” section and navigate to the particular component. For example, to know all the available options in DatePicker check the following link,
http://helpjs.syncfusion.com/js/api/ejdatepicker
For getting started and to know about the important features in any particular component, go to the help link and click on the particular component. For example, getting started and key features in DatePicker can be found in
http://helpjs.syncfusion.com/js/datepicker/overview

Please let us know if you have further queries.
 
Regards,
Gopal L


AC Aubyn Crawford August 17, 2015 02:52 PM

I understand (now!) the relationship there, I knew there had to be a simple explanation - glad I posted. Thanks  


GL Gopal Lakshmanan Syncfusion Team August 18, 2015 12:38 AM

Hi Aubyn,
           Thanks for the update, please let us know if need further asssitance.
 
 
Regards,
Gopal.L



Loader.
Live Chat Icon For mobile
Up arrow icon