This is a migrated thread and some comments may be shown as answers.

RadAsyncUpload Persist Additional Fields on Post Back

4 Answers 121 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 1
Elliott asked on 08 Jan 2013, 03:42 PM
Hi there,

I'm doing something similar to this demo where it adds a field when the file is uploaded. Additionally, I've followed these steps to "Persist Uploaded Files". However on Post Back it retained the uploaded files, but doesn't retain the additional field added or the values in the text box. Is there just something I'm missing, or how would I be able to achieve this?

Thanks,
Elliott

4 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 11 Jan 2013, 10:03 AM
Hi Elliott,

 
This is expected behavior because the additional fields are created on the fly on the client and are not saved to the server or in some state. One possible workaround is to add the same fields again on pageload client event if RadAsyncUpload has some uploaded files.

Hope this will be helpful. 
 

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 06 Mar 2014, 06:58 PM
Are there any examples on how to do this?  I am running into the same problem.

I have been able to add the same fields on pageload by looping through the <li> rows of the previously uploaded files on postback.  I have tried various numbering schemes for the IDs and their containers (0-based, offset by 1, 10, etc.) but no matter what, I get a collision between the recreated fields and the newly (dynamically created fields) after a postback.

For example, I will upload files with descriptions of ("red", "green", "blue"), do a postback, then upload a new file with the description "orange".  When I save the page, the results are as follows: ("red,orange", "green", "blue", "red,orange").  The Telerik control seems to be reading the recreated fields as well as any new fields using a 0-based index, and I can't seem to change this.

0
John
Top achievements
Rank 1
answered on 07 Mar 2014, 05:36 PM
The problem seems to be with the _ClientState field, which holds JSON data for each uploaded file.  The "Index" property of the files is as follows: (0, 1, 0, 1).  The first two files were uploaded before the postback, and the second two after the postback.  This would explain why the third and fourth description fields are overwriting the first two on the final save.  I'm trying to manipulate this field directly in Javascript now, but that seems like a bad hack.  Any suggestions?

{
   'isEnabled':'true',
   'uploadedFiles':[
      {
         "fileInfo":{
            "FileName":"Chrysanthemum.jpg",
            "ContentType":"image/jpeg",
            "ContentLength":879394,
            "DateJson":"2009-07-14T05:32:31.000Z",
            "Index":0
         },
         "metaData":"CS8S/Z0J/b2982DRxDin0BBslA7fI0cWMuWlPu4W3FmFdzftFw+8kJpPRUpzx5xPI54x9amdfCqrpRGdvJBDtRxc6qqBtmPOkDLu1Ow3A59Js8XP/W1TPx46o5qahdOB3eqx//yxxNtlXGo51G2++DdY6D9Eoa5oSxp6YsYAFt49nOf3SlmcfBSI+dJSiVumBB/XAHWY2SsJnPDM20N/saYALckp5AHhPIOin04o5f4ZXfIDmVb2EP+FNQPJocgdlOSjAufVh0ZNmhPdNzmU7FGkHHMUbpZj2tVk88v5ZDdXRQHNYbd3depmK/Ri0Dt49GyHCuAhkh+zTfKmUJ9coHQTFz+TcJjTUlnWa+MFctu9rJh943tZDYq9pg6jTh+6eZkNyHSzeb0ueZCkWjPVXv742tH3CSXpoS41aZq4w9mPeJ3iUBvHVs4A8iKCJPNaCXMZtWtm3WGuu05jvhnRr6VFq9jdmvhdnIvso86XVnW9qld9AbEF4Cranfi7zg5hyfZK/ofA48lDp2o1j0k26Q=="
      },
      {
         "fileInfo":{
            "FileName":"Desert.jpg",
            "ContentType":"image/jpeg",
            "ContentLength":845941,
            "DateJson":"2009-07-14T05:32:31.000Z",
            "Index":1
         },
         "metaData":"CS8S/Z0J/b2982DRxDin0BBslA7fI0cWMuWlPu4W3FmFdzftFw+8kJpPRUpzx5xPm/1ptOD6Ws3I12DybQ6A5DzCB7Mm5vXRQJgJaq+6bCZzY9/KoGYdFzfqcOUm0b/1YZ0PzX4hxiH7dSKfyiyAu7+0fBTI2cIs9ja5xlbFH6FZdrsXhWGUDLTGdcd8iE0mi+bRFWDKVo7dteoF8h05UzgUrtpufr4cCLxFLUsnhCgKQcKo+Y8OYW1+EF0TQNebtXsGRCulHYQqD7rTZxkzalaq/3ETjlQVxP8zr2dIA5nDGCssw2E9xCTZsDO2v516/jEAYaYPpDNlJw0dXHulCdLS9xLt8NWXaRUm03vbJEouFObSBtRnH/hYoYQoNHluSFqJRO/O/3IiDcWZFZSRJaPOUwxekYwDfiIXAhpXchjLZQtzn9abBgnhx2Tm86rAs6B3c0RIu4HOS2qxetqvLxB+CXg0gjb3oqmkMo4BbhTFgnNEhISrddM222KSICvy"
      },
      {
         "fileInfo":{
            "FileName":"Koala.jpg",
            "ContentType":"image/jpeg",
            "ContentLength":780831,
            "DateJson":"2009-07-14T05:32:31.000Z",
            "Index":0
         },
         "metaData":"CS8S/Z0J/b2982DRxDin0BBslA7fI0cWMuWlPu4W3FmFdzftFw+8kJpPRUpzx5xPbRTEUG3W2cRWt4qq5c8yFQ3r955XssXJM5nNQHeEunl9LwYGtIMNMXPrBTg5MnWQJ3lCeo5CHz/4N1cl9iB36HKXpXWo1Wf4cKteo2KVdtLDcN6lrnymVxWNsVYTEnGMvD9hMxfMcyRYRDTAtzowqSl1pvO/UleFICPk3pjtArArK166DoA7UBCO8f4+bNlKNElYqav4pQfB//w/aB1Ioeq7wPWauGakdOIY8ISqFTkCCZTeYjB72ue7F9gUMaXPy6GHb2mTeATlBG8UX1uAYaBXVIAEhIBxsJcJvU34bmiyrGIv3b+xckSFa/TPyxMRGnXZtoCdhE/LGbB1PfPQ+oI4v1tQ/n4oI6GBZtw2sZVSy0A1t5qch3BXHxw0mltoYV6H48yWGuQg7p7BA0JlaDnb27oUIbvBcwko4o0zFjhQfY9v7ZKVWlVzuRIxSY+G"
      },
      {
         "fileInfo":{
            "FileName":"Lighthouse.jpg",
            "ContentType":"image/jpeg",
            "ContentLength":561276,
            "DateJson":"2009-07-14T05:32:31.000Z",
            "Index":1
         },
         "metaData":"CS8S/Z0J/b2982DRxDin0BBslA7fI0cWMuWlPu4W3FmFdzftFw+8kJpPRUpzx5xPUbFG0zE2zj9rZMDDZs9v5TOu5QCeo+rGK9QOaGiPEbkHcRUXECM1t2e18QJWDFfp4sy2UPuxGYJVjH83OtMAFm1wZZqhWeJT4dnWMTjLnWvzLBGKD3q1/JBFQ+w/9kn3fSRj2vwu9hKOOwyOaV6KavAxq/JWcm9A9YvRievmlBuC1CO/ZY0Y+vY1xE+EqCS+HvNVsqZftKy11JchNUz+68ec0Z+cX0I27J3yiPWiRbUrB0cIN8vrtPSIPQn3NyvQ+M6ZnrAig8Azrr2uY0fuHqayQD83HS1wi+6UAnv1phALepDo2RzbL9rAGTCnQjFfeILzF3CrzVHn8LAwSp72gT6n0vfwySz+sE/V+pzsa2/JjcUQjDC3/qbiLqvj9VtbyPl6NcnEqhyrR7WSFzW5HYs7arcmj1WsRZ+enul5E4vsF6j6UhkJcUfhrhUfRaB74BDhdjV3RpcxoS89FyoOhA=="
      }
   ]
}
0
John
Top achievements
Rank 1
answered on 07 Mar 2014, 07:28 PM
I ended up finding a much simpler approach...  On the server-side save routine, I simply used the same description values stored in my hidden field (pipe-delimited) and incremented through those in the "foreach (UploadedFile file in raUpload.UploadedFiles)" loop.  The indexes of the descriptions match the order of the uploaded files.

Tags
AsyncUpload
Asked by
Elliott
Top achievements
Rank 1
Answers by
Plamen
Telerik team
John
Top achievements
Rank 1
Share this question
or