Validation of other controls before uploading

7 posts, 1 answers
  1. K W
    K W avatar
    9 posts
    Member since:
    May 2010

    Posted 07 May 2014 Link to this post

    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?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 May 2014 in reply to K W Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. K W
    K W avatar
    9 posts
    Member since:
    May 2010

    Posted 07 May 2014 in reply to Princy Link to this post

    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). 
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 May 2014 in reply to K W Link to this post

    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.
  6. K W
    K W avatar
    9 posts
    Member since:
    May 2010

    Posted 08 May 2014 in reply to Princy Link to this post

    Thanks for the answer!
  7. Brian
    Brian avatar
    8 posts
    Member since:
    Feb 2012

    Posted 02 Aug 2014 in reply to Princy Link to this post

    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. 
  8. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Aug 2014 in reply to Brian Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017