RedAsynUpload Cotrol validation.

Thread is closed for posting
3 posts, 0 answers
  1. Deepak
    Deepak avatar
    9 posts
    Member since:
    Aug 2010

    Posted 03 Jan 2011 Link to this post

    Hi,
    I have try many time to use the Asp Required field validater with RedAsynUpload Cotrol but it always throw error.
    So its any resource or method are available, so that i can apply facility as Required field validater with Red asyn upload control .
    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Jan 2011 Link to this post

    Hello Deepak,

    You can achieve the same with CustomValidator. Here is the sample code.

    JavaScript:
    <script type="text/javascript">
        function validation(sender, args)
        {
            var file = $find("RadAsyncUpload1");
           if (file.getUploadedFiles().length == 0)
          {
                args.IsValid = false;
          }
        }
    </script>

    ASPX:
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" TargetFolder="~/Uploads">
    </telerik:RadAsyncUpload>
    <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validation"
                ErrorMessage="Select File!!">
    </asp:CustomValidator>
    <asp:Button ID="Button1" runat="server" Text="Submit" />

    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Deepak
    Deepak avatar
    9 posts
    Member since:
    Aug 2010

    Posted 03 Jan 2011 Link to this post

    Hi
    here i am post my .aspx page.
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <div class="fromContainer">
            <h1>
                <asp:Label runat="server" ID="lblHeader" Text="Why I love Kiwanis" />
            </h1>
            <img src="Images/btnAdd.jpg" class="btnAdd" id="Add" />
            <div style="clear: both;">
            </div>
            <asp:UpdateProgress runat="server" ID="UpdateProgress2" AssociatedUpdatePanelID="UpdatePanel1">
                <ProgressTemplate>
                    <div class="progressBar">
                        <img id="imgUP2" runat="server" src="~/Images/update.gif" />
                        <span>Loading ...</span>
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
            <div id="panleText" class="tabPanel">
                <h2>
                    Add your story and photo here!
                </h2>
            </div>
            <div id="panelMain">
                <asp:UpdatePanel runat="server" ID="UP">
                    <ContentTemplate>
                        <div class="bottomBgBox">
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <table class="tblBasicForm">
                                            <tr>
                                                <td>
                                                    First Name
                                                </td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtFirstName" CssClass="input" ToolTip="Enter Your First Name" />
                                                </td>
                                                <td>
                                                    <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName"
                                                        ErrorMessage="*" ValidationGroup="Submit" ForeColor="Red"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Last Name
                                                </td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtLastName" CssClass="input" ToolTip="Enter Your Last Name" />
                                                </td>
                                                <td>
                                                    <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ControlToValidate="txtLastName"
                                                        ErrorMessage="*" ValidationGroup="Submit" ForeColor="Red"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Club Name
                                                </td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="txtClub" CssClass="input" ToolTip="Enter Club Name" />
                                                </td>
                                                <td>
                                                    <asp:RequiredFieldValidator ID="rfvClub" runat="server" ControlToValidate="txtClub"
                                                        ErrorMessage="*" ValidationGroup="Submit" ForeColor="Red"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                                            <ContentTemplate>
                                                <table class="tblOptionalForm">
                                                    <tr>
                                                        <td>
                                                            Country
                                                        </td>
                                                        <td>
                                                            <telerik:RadComboBox ID="ddlCountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_OnSelectedIndexChanged"
                                                                ToolTip="Select the country">
                                                            </telerik:RadComboBox>
                                                            <asp:RequiredFieldValidator ID="rfvDdlCountry" runat="server" ControlToValidate="ddlCountry"
                                                                Display="Dynamic" ErrorMessage="*" ValidationGroup="Submit" InitialValue="0"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            State
                                                        </td>
                                                        <td>
                                                            <telerik:RadComboBox ID="ddlState" runat="server" AutoPostBack="true" CssClass="input">
                                                            </telerik:RadComboBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            City
                                                        </td>
                                                        <td>
                                                            <telerik:RadComboBox ID="ddlCity" runat="server" CssClass="input" ToolTip="Select the City">
                                                            </telerik:RadComboBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="discriptionBox">
                            Discription
                            <br />
                            <asp:TextBox CssClass="input" runat="server" ID="txtDiscription" TextMode="MultiLine" />
                            <asp:RequiredFieldValidator ID="rfvDescription" ControlToValidate="txtDiscription"
                                ErrorMessage="Required field can not be empty" ForeColor="Red" runat="server"
                                ValidationGroup="Submit"></asp:RequiredFieldValidator>
                            <br />
                            Photo Upload
                            <br />
                            <br />
                            <telerik:RadAjaxPanel runat="server" RestoreOriginalRenderDelegate="false">
                                <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" ControlObjectsVisibility="None"
                                    TargetFolder="~/Record/" ToolTip="Upload the Image" AllowedFileExtensions=".jpeg,.png,.gif">
                                </telerik:RadAsyncUpload>
                                <asp:CustomValidator runat="server" ID="CustomValidator" ValidationGroup="Submit" ClientValidationFunction="validation"
                                     Display="Dynamic" ErrorMessage="Select File!!">
                                </asp:CustomValidator>
                            </telerik:RadAjaxPanel>
                            <br />
                            <div class="captchaText">
                                Enter the capcha text here
                                <asp:TextBox ID="CaptchaInput" CssClass="captchaBox" runat="server" MaxLength="5"
                                    Font-Size="13px" ToolTip="Right Down The Captcha Test" />
                                <asp:RequiredFieldValidator ID="ddd" runat="server" ControlToValidate="CaptchaInput"
                                    ValidationGroup="Submit" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
                            </div>
                            <telerik:RadCaptcha ID="RadCaptcha2" runat="server" CaptchaImage-RenderImageOnly="true"
                                CssClass="captcha" CaptchaImage-BackgroundColor="#efefef" ErrorMessage="The code you entered is not valid"
                                Display="Dynamic" CaptchaTextBoxCssClass="captchaBox" ImageStorageLocation="Cache"
                                EnableViewState="true" ValidatedTextBoxID="CaptchaInput" ValidationGroup="Submit">
                            </telerik:RadCaptcha>
                            <asp:ImageButton runat="server" ID="btnUpload" CssClass="btnAdd" ImageUrl="~/Images/btnUpload.jpg"
                                OnClick="btnUpload_OnClick" ValidationGroup="Submit" ToolTip="Click On Submit Button" />
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <script language="javascript" type="text/javascript">
                $(function () {
     
                    $(".btnAdd").click(function () {
                        $(".tabPanel").slideUp();
                        $("#panelMain").slideDown();
                    });
                })
            </script>
            </>
            <asp:UpdatePanel runat="server" ID="UP1">
                <ContentTemplate>
                    <div id="mapContainer">
                        <h1>
                            Map
                        </h1>
                        <br />
                        <asp:UpdateProgress runat="server" ID="PageUpdateProgress" AssociatedUpdatePanelID="UP1">
                            <ProgressTemplate>
                                <div class="progressBar">
                                    <img id="imgUP1" runat="server" src="~/Images/update.gif" />
                                    <span>Loading ...</span>
                                </div>
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <div>
                            <div class="gMap">
                                <cc1:GMap ID="GMap1" runat="server" Width="540" Height="400" serverEventsType="AspNetPostBack"
                                    OnMarkerClick="Gmap1_OnMarkerClick" enableServerEvents="true" OnClick="Gmap1_OnClick"
                                    OnZoomEnd="Gmap1_OnZoomEnd" />
                            </div>
                            <div class="regionListContainer">
                                <h3>
                                    <asp:Label runat="server" ID="lblRegionListHeader" Text="Continent Regions" />
                                </h3>
                                <asp:ListBox runat="server" ID="listRegion" CssClass="regionList" OnSelectedIndexChanged="listRegion_OnSelectedIndexChanged"
                                    AutoPostBack="true" />
                                <div class="listContainerBottom">
                                    <img src="Images/DownArrow.jpg" />more
                                </div>
                            </div>
                        </div>
                    </div>
                    </div>
                    <div id="descriptionContainer">
                        <asp:FormView ID="fvTestimonial" runat="server" PagerSettings-NextPageImageUrl="~/Images/btnNext.jpg"
                            AllowPaging="true" OnPageIndexChanging="fvTestimonial_OnPageIndexChanging" PagerSettings-LastPageImageUrl="~/Images/btnBack.jpg"
                            PagerSettings-Mode="NextPrevious">
                            <PagerTemplate>
                            </PagerTemplate>
                            <ItemTemplate>
                                <h1>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("City.Name") %>' />
                                </h1>
                                <div class="hr">
                                    <div class="testiNavContainer">
                                        <asp:ImageButton runat="server" ID="ibtnPrevious" CommandName="Page" CommandArgument="Prev"
                                            ImageUrl="~/Images/btnBack.jpg" />
                                        <asp:ImageButton runat="server" ID="ibtnNext" CommandName="Page" CommandArgument="Next"
                                            ImageUrl="~/Images/btnNext.jpg" />
                                    </div>
                                </div>
                                <div class="discription">
                                    <asp:Image runat="server" ID="imgPhoto" Width="380" CssClass="discriptionImage" ImageUrl='<%# Bind("FileUrl") %>'
                                        Visible='<%# Eval("FileUrl")!= null %>' />
                                    <div style="float: left" class="discriptionText">
                                        <p>
                                            <asp:Label ID="lblDiscription" runat="server" Text='<%# Bind("Desciption") %>' />
                                        </p>
                                        <p>
                                            <asp:Label ID="lblFirstName" CssClass="highlight" runat="server" Text='<%# Bind("FirstName") %>' />
                                            <asp:Label ID="lblLastName" CssClass="highlight" runat="server" Text='<%# Bind("LastName") %>' />,
                                            <br />
                                            <asp:Label ID="lblCity" runat="server" Text='<%# Bind("City.Name") %>' />,
                                            <asp:Label ID="lblCountry" runat="server" Text='<%# Bind("Country.Name") %>' />
                                        </p>
                                    </div>
                                </div>
                                <br />
                            </ItemTemplate>
                        </asp:FormView>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
    </asp:Content>
    In <telerik:RadAjaxPanel runat="server" RestoreOriginalRenderDelegate="false">
                                <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" ControlObjectsVisibility="None"
                                    TargetFolder="~/Record/" ToolTip="Upload the Image" AllowedFileExtensions=".jpeg,.png,.gif">
                                </telerik:RadAsyncUpload>
                                <asp:CustomValidator runat="server" ID="CustomValidator" ValidationGroup="Submit" ClientValidationFunction="validation"
                                     Display="Dynamic" ErrorMessage="Select File!!">
                                </asp:CustomValidator>
                            </telerik:RadAjaxPanel>
    want to use required field validation for this rad upload.
    Thanks
Back to Top