New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Server-side Validation

Validate your uploads

  • Allowed files count: up to 2 files
  • Captcha validation: Enter the correct code from the image

Our validation demo demonstrates an easy way of combining RadAsyncUpload and the server-side validation of the RadCaptcha control. The control will fire its FileUpload event and process the files if the Page is valid. The uploaded files are persisted between postbacks if the Page is not valid.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="AsyncUpload.Examples.Validation.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-medium">
        <div class="qsf-demo-canvas">
            <h2>Validate your uploads</h2>
            <ul class="qsf-list">
                <li>
                    <strong>Allowed files count:</strong> up to 2 files
                </li>
                <li>
                    <strong>Captcha validation:</strong> Enter the correct code from the image
                </li>
            </ul>
            <telerik:RadCaptcha Skin="Silk" runat="server" CaptchaImage-RenderImageOnly="true" CaptchaTextBoxLabel="" ID="RadCaptcha1" ValidationGroup="CaptchaValidation" OnCaptchaValidate="RadCaptcha1_CaptchaValidate"></telerik:RadCaptcha>
            <asp:TextBox runat="server" ID="ValidationInput" CssClass="validationInput"></asp:TextBox>
            <telerik:RadAsyncUpload RenderMode="Lightweight" runat="server" EnableCustomValidation="true" ID="RadAsyncUpload1" MultipleFileSelection="Automatic"
                Skin="Silk" OnFileUploaded="RadAsyncUpload1_FileUploaded"  >
            </telerik:RadAsyncUpload>

            <div class="qsf-results">
                <telerik:RadButton RenderMode="Lightweight" runat="server" Skin="Silk" ID="BtnSubmit" ValidationGroup="CaptchaValidation" 
                      Text="Validate the uploaded files"></telerik:RadButton>


                <asp:Panel ID="ValidFiles" Visible="false" runat="server" CssClass="qsf-success">
                    <h3>You successfully uploaded:</h3>
                    <ul class="qsf-list" runat="server" id="ValidFilesList"></ul>
                </asp:Panel>

                <telerik:RadButton RenderMode="Lightweight" Skin="Silk" ID="RefreshButton" runat="server" OnClick="RefreshButton_Click" Visible="false" Text="Back" ></telerik:RadButton>
            </div>

            <div class="qsf-decoration"></div>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance