Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
65 views
I have a composite control that has a link button and RadAyncUpload in RadDataForm.
I access the control as follows using Javascript in a  WebForm.

var filelength = find("<%= CompositeControl1.RadAsyncUpload.ClientID %>").getUploadedFiles().length;

I am not sure how to access this control using javascript from RadDataForm.

I tried using the following,

 var container = $(".RadDataForm")[0];
 var uploaded = $telerik.findElement(container, "CompositeControl1");

I am not sure how to access RadAsyncUpload from the above.Any help is appreciated.Thank you.
T
Top achievements
Rank 1
 asked on 21 Feb 2022
0 answers
124 views
Does RadDataForm support validation? I want to add RequiredFieldValidator and do a server side validation.
I am using DataForm with SelectMethod/UpdateMethod (Model Binding) and ValidationSummary.
I start the form in Edit Mode.

When I click Update and the field is empty, update method does not get called. There are no errors displayed on the page though. I can see that NameCustomValidator_ServerValidate method is called and it sets IsValid to false.

If the field is not empty then update method is called and works as expected.

I am using version 2017.2.711.45

I was able to successfully use validation with RadGrid.

My code...

<asp:ValidationSummary ID="ValidationErrors" runat="server" />
 
<telerik:RadDataForm ID="DataForm" runat="server" SelectMethod="GetDetails" UpdateMethod="UpdateDetails"
            ItemType="MyData" DataKeyNames="ID"
            OnPreRender="DataForm_PreRender" ItemPlaceholderID="itemPlaceholder1">
    <LayoutTemplate>
        <div id="itemPlaceholder1" runat="server"></div>
    </LayoutTemplate>
    <ItemTemplate>Empty Read Only Page</ItemTemplate>
    <EditItemTemplate>
        <div>
            <telerik:RadButton ID="InsertButton1" runat="server" ButtonType="StandardButton" CommandName="Update" Text="Update" />
            <telerik:RadButton ID="CancelButton1" runat="server" ButtonType="StandardButton" CausesValidation="False" CommandName="Cancel" Text="Cancel Changes" />
        </div>
        <table>
            <tr>
                <td><telerik:RadLabel ID="NameLabel" runat="server" AssociatedControlID="NameTBox">Name:</telerik:RadLabel></td>
                <td>
                    <telerik:TextBox ID="NameTBox" runat="server" Text="<%# BindItem.Name %>"></telerik:TextBox>
                    <asp:RequiredFieldValidator ID="NameValidator" runat="server" ControlToValidate="NameTBox" ErrorMessage="Name is required" Text="!" Display="Static" />
                    <asp:CustomValidator ID="NameCustomValidator" runat="server" ControlToValidate="NameTBox" OnServerValidate="NameCustomValidator_ServerValidate" ErrorMessage="Name is required" Text="!" Display="Static" />
                </td>
            </tr>
        </table>
     </EditItemTemplate>
</telerik:RadDataForm>

 

Start DataForm in edit mode

protected void DataForm_PreRender(object sender, EventArgs e)
{
    // Display Edit mode when first loaded
    // Stay in Edit mode after update
    RadDataForm editForm = (RadDataForm) sender;
    if (editForm.Items.Count() > 0)
    {
        RadDataFormItem item = editForm.Items[0];
        item.FireCommandEvent("Edit", "");
    }
}

This does get called.

protected void NameCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
    args.IsValid = !string.IsNullOrEmpty(args.Value);
}

 

Thanks

Marius
Top achievements
Rank 1
 asked on 27 Sep 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?