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

How to Validate RadFileUpload which is inside Radgrid ?

1 Answer 66 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
ashok kumar
Top achievements
Rank 1
ashok kumar asked on 18 Mar 2010, 07:44 PM
Hello ,

i would like to know how to validate RadFileUpload which is inside the FormTemplate of EditFormSettings in rad grid .

i wonder if this could be possible and i was not able to find any similar post of my kind of issue.

i would like to know the client side validation and server side validation of it .

i have pasted the code which am using right now ,  you can see for the control ID -  RUPhoto

please advise your ideas.

<telerik:RadGrid ID="RadGridHodesTeam" runat="server" GridLines="None" AllowPaging="true" 
                    EnableEmbeddedSkins="false" PageSize="4" OnNeedDataSource="RadGridHodesTeam_NeedDataSource" 
                    Skin="Office2007" OnPreRender="RadGridHodesTeam_PreRender" OnInsertCommand="RadGridHodesTeam_InsertCommand"
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                    <MasterTableView TableLayout="Auto" DataKeyNames="ID,Name,Title,OfficePhone,Extension,SecondPhone,Extension1,Fax,Email" 
                        CommandItemDisplay="TopAndBottom" ShowHeader="false"
                        <ItemTemplate> 
                            <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %> 
                            <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>' 
                                runat="server" Height="200px"
                                <div class="itempadding"
                                    <table> 
                                        <tr visible="false" style="display: none;"
                                            <td> 
                                                <b>Id:</b></td
                                            <td> 
                                                <%#Eval("ID")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>Name:</b></td
                                            <td> 
                                                <%#Eval("Name")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>Title:</b></td
                                            <td> 
                                                <%# Eval("Title")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>Phone:</b></td
                                            <td> 
                                                <%# Eval("OfficePhone")%> 
                                            </td> 
                                        </tr> 
                                        <tr visible="false" style="display: none;"
                                            <td> 
                                                <b>Extension:</b></td
                                            <td> 
                                                <%# Eval("Extension")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>Mobile:</b></td
                                            <td> 
                                                <%# Eval("SecondPhone")%> 
                                            </td> 
                                        </tr> 
                                        <tr visible="false" style="display: none;"
                                            <td> 
                                                <b>Extension:</b></td
                                            <td> 
                                                <%# Eval("Extension1")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>Fax:</b></td
                                            <td> 
                                                <%# Eval("Fax")%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                <b>EMail:</b></td
                                            <td> 
                                                <%# Eval("Email")%> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                    <table id="Table1" style="height: 25px; display: block;" runat="server"
                                        <tr id="trBtns"
                                            <td align="center"
                                                <href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"ID")%>');return false;"
                                                    Edit </a> 
                                            </td> 
                                            <td align="center"
                                                <href="#" onclick="openRadWindow1('<%#DataBinder.Eval(Container.DataItem,"ID")%>');return false;"
                                                    Delete </a> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </div> 
                            </asp:Panel> 
                        </ItemTemplate> 
                        <EditFormSettings EditFormType="Template"
                            <FormTemplate> 
                                <div style="width: 100%"
                                    <table align="center"
                                        <tr> 
                                            <td> 
                                                Name: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadtxtName" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RequiredFieldValidator ID="rfvtxtName" ControlToValidate="RadtxtName" runat="server" 
                                                    Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator></td
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                Title: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtTitle" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RequiredFieldValidator ID="rfvRadTxtTitle" ControlToValidate="RadTxtTitle" runat="server" 
                                                    Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator></td
                                        </tr> 
                                        <tr style="width: 200px;"
                                            <td> 
                                                Phone: 
                                            </td> 
                                            <td class="recordsfields"
                                                <telerik:RadTextBox ID="RadTxtOfficePhone" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RequiredFieldValidator ID="rfvRadTxtOfficePhone" CssClass="padding10px" ControlToValidate="RadTxtOfficePhone" 
                                                    runat="server" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator> 
                                                <asp:RegularExpressionValidator ID="revRadTxtOfficePhone" runat="server" ErrorMessage="Number Is Not Valid!!" 
                                                    Display="Dynamic" CssClass="padding10px" ControlToValidate="RadTxtOfficePhone" 
                                                    ValidationExpression="^[0-9-+]*$"></asp:RegularExpressionValidator></td
                                        </tr> 
                                        <tr visible="false" style="display: none;"
                                            <td> 
                                                Extension: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtOfficeExt" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RegularExpressionValidator ID="revRadTxtOfficeExt" runat="server" ErrorMessage="Number Only !!" 
                                                    ControlToValidate="RadTxtOfficeExt" ValidationExpression="^\d+$"></asp:RegularExpressionValidator> 
                                                <%--<asp:RequiredFieldValidator ID="rfvRadTxtOfficeExt" ControlToValidate="RadTxtOfficeExt" 
                                                        runat="server" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                Mobile: 
                                            </td> 
                                            <td class="recordsfields"
                                                <telerik:RadTextBox ID="RadTxtSecondPhone" runat="server"
                                                </telerik:RadTextBox> 
                                                <%--<asp:RequiredFieldValidator ID="rfvRadTxtSecondPhone" ControlToValidate="RadTxtSecondPhone" 
                                                        runat="server" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%> 
                                                <asp:RegularExpressionValidator ID="revRadTxtSecondPhone" runat="server" ErrorMessage="Number Is Not Valid !!" 
                                                    CssClass="padding10px" ControlToValidate="RadTxtSecondPhone" ValidationExpression="^[0-9-+]*$"></asp:RegularExpressionValidator></td
                                        </tr> 
                                        <tr visible="false" style="display: none;"
                                            <td> 
                                                Extension: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtSecondExtension" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RegularExpressionValidator ID="revRadTxtSecondExtension" runat="server" ErrorMessage=" Number Only !!" 
                                                    ControlToValidate="RadTxtSecondExtension" ValidationExpression="^\d+$"></asp:RegularExpressionValidator> 
                                                <%--<asp:RequiredFieldValidator ID="rfvRadTxtExtension" ControlToValidate="RadTxtSecondExtension" 
                                                        runat="server" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                Fax: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtFax" runat="server"
                                                </telerik:RadTextBox> 
                                                <%--<asp:RequiredFieldValidator ID="rfvRadTxtFax" ControlToValidate="RadTxtFax" runat="server" 
                                                    Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>--%> 
                                                <asp:RegularExpressionValidator ID="revRadTxtFax" runat="server" ErrorMessage="Invalid Format" 
                                                    Display="Dynamic" ControlToValidate="RadTxtFax" ValidationExpression="^[0-9-+]*$"></asp:RegularExpressionValidator> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                EMail: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtEmail" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RequiredFieldValidator ID="rfvRadTxtEmail" ControlToValidate="RadTxtEmail" runat="server" 
                                                    Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator> 
                                                <asp:RegularExpressionValidator ID="revRadTxtEmail" runat="server" ErrorMessage="Email Not Valid!" 
                                                    Display="Dynamic" ControlToValidate="RadTxtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                Photo: 
                                            </td> 
                                            <td> 
                                                <telerik:RadUpload ID="RUPhoto" runat="server" ControlObjectsVisibility="None" AllowedFileExtensions=".jpg,.jpeg" 
                                                    Skin="Office2007"
                                                </telerik:RadUpload> 
                                                <br /> 
                                                <%--<asp:Label ID="lblerr" runat="server" Text="Invalid File" Visible="false" ></asp:Label>--%> 
                                                Image size should be 145 x 55 px 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                                Team Member URL: 
                                            </td> 
                                            <td> 
                                                <telerik:RadTextBox ID="RadTxtTeamMember" runat="server"
                                                </telerik:RadTextBox> 
                                                <asp:RegularExpressionValidator ID="RevRadTxtTeamMember" runat="server" ErrorMessage="URL Invalid" 
                                                    ControlToValidate="RadTxtTeamMember" ValidationExpression="^(ht|f)tp(s?)\:\/\/(([a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+)+)|localhost)(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?([\d\w\.\/\%\+\-\=\&amp;\?\:\\\&quot;\'\,\|\~\;]*)$"
                                                </asp:RegularExpressionValidator> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td> 
                                            </td> 
                                            <td> 
                                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
                                                </asp:Button> 
                                                <asp:Button ID="BtnCancel" runat="server" Text="Cancel" CausesValidation="false" 
                                                    CommandName="Cancel" /></td
                                        </tr> 
                                    </table> 
                                </div> 
                            </FormTemplate> 
                        </EditFormSettings> 
                    </MasterTableView> 
                    <GroupingSettings CaseSensitive="false" /> 
                </telerik:RadGrid> 


Thanks in Advance ,

Ashok.c

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 22 Mar 2010, 06:03 PM
Hello ashok kumar,

You can find sample project that demonstrates how to validate RadUpload inside edit template as an attachment.

Best wishes,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Upload (Obsolete)
Asked by
ashok kumar
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or