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

Validation of other controls before uploading

8 Answers 50 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
K W
Top achievements
Rank 1
K W asked on 07 May 2014, 11:11 AM
I have a basic form - a few drop downs and textboxes - and a RadAsyncUpload control.
On submission of the form checks are carried out (e.g. has an option been selected from the dropdown?). If there is missing information an error message appears. However at this point the async control loses the file. 

Is there a way to complete these validation checks for other controls and retain the file in the async control?

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 07 May 2014, 12:51 PM
Hi,

RadAsyncUpload provides PostbackTriggers property which can be used to persist the information for the successfully uploaded files after a postback. Using that property the information about successfully uploaded files will be persisted after every postback until an exact control triggers a postback. When a postback is triggered from a control which ID is contained by PostbackTriggers property all the information for the uploaded files will become available on the server side. Please have a look into this help documentation for further information.

Thanks,
Princy.
0
K W
Top achievements
Rank 1
answered on 07 May 2014, 02:32 PM
Thanks for replying. I have placed a postback trigger on the control but the problem I have is that the validations are run on the submit button which is the postback trigger for the async control, as I wanted this to take place on one Submit button. (i.e check all data correct and then submit or if data missing show error and retain all current selections and uploads). 
0
Accepted
Princy
Top achievements
Rank 1
answered on 08 May 2014, 09:48 AM
Hi,

Please take a look into sample code snippet I tried with your scenario. Here the validation is done from client side. So the post back only happen after successful validation.

ASPX:
<telerik:RadComboBox ID="radcboValidate" runat="server" ValidationGroup="Submit"
    EmptyMessage="- Choose one -">
    <Items>
        <telerik:RadComboBoxItem Text="Yes" Value="1" />
        <telerik:RadComboBoxItem Text="No" Value="2" />
    </Items>
</telerik:RadComboBox>
<br />
<asp:RequiredFieldValidator runat="server" ID="rfvValidateCombo" ControlToValidate="radcboValidate" ValidationGroup="Submit" ErrorMessage="Please Choose one" />
<br />
<telerik:RadTextBox ID="radtxtValidate" runat="server" ValidationGroup="Submit">
</telerik:RadTextBox>
<br />
<asp:RequiredFieldValidator runat="server" ID="rfvValidateTextbox" ControlToValidate="radtxtValidate" ValidationGroup="Submit" ErrorMessage="Required" />
<br />
<telerik:RadAsyncUpload ID="radasynuplFile" runat="server">
</telerik:RadAsyncUpload>
<telerik:RadButton ID="radbtnSubmit" runat="server" Text="Submit" ValidationGroup="Submit">
</telerik:RadButton>

Thanks,
Princy.
0
K W
Top achievements
Rank 1
answered on 08 May 2014, 01:29 PM
Thanks for the answer!
0
Brian
Top achievements
Rank 1
answered on 02 Aug 2014, 04:28 PM
How do you persist the files if a server validation error occurs?

we've got some business login on a webform that needs to do database lookup for validation.  If an error occurs we do the following:

Page.ModelState.AddModelError("", "Database error");

Upon returning from form postback, the error is displayed but the selected file list from RadAsynUpload is lost.  So it doesn't appear this control supports true forms validation. 
0
Princy
Top achievements
Rank 1
answered on 04 Aug 2014, 03:45 AM
Hi Brain,

RadAsyncUpload provides client-side event called OnClientValidationFailed. It is fired when an Invalid File is trying to upload.For the server side validation you can use the FileUploaded event which will fire separately for each and every uploaded file. Each file can be marked as a valid or invalid using the IsValid property of FileUploadedEventArgs. It is not possible to get the Invalid File on the server side this is the default behavior of the control.

Thanks,
Princy.
0
Shaun
Top achievements
Rank 1
answered on 05 Jan 2017, 09:15 AM
Elsewhere it looks as though they've skirted the server side validation issue by validating in PageInit and then only setting the PostbackTriggers property if it validated successfully, you can see it here: http://www.telerik.com/support/code-library/validating-a-file-upload-with-the-radcaptcha-de3d44ddd82d
0
Veselin Tsvetanov
Telerik team
answered on 10 Jan 2017, 07:39 AM
Hi Shaun,

Yes, indeed, the Validating a file upload with the RadCaptcha code library demonstrates how to perform server validation (of other controls) and persist the uploaded files if the validation fails.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
AsyncUpload
Asked by
K W
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
K W
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Shaun
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or