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

Client Side Validation with Nested UserControl and Ajax Manager

3 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 18 Jun 2012, 06:49 AM
How do I get a Nested User Control to use client-side validation?

Here's the validator:
<telerik:RadTextBox ID="txtAuditor" runat="server">
</telerik:RadTextBox>
<asp:RequiredFieldValidator runat="server" ID="rfvAuditor" ControlToValidate="txtAuditor"
    ErrorMessage="Auditor is required" Display="Dynamic" ForeColor="Red" ValidationGroup="Audit">*</asp:RequiredFieldValidator>


My user control has "btnUpdate" is inside the User Control:
<telerik:RadButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" ValidationGroup="Audit">

The user control includes the Validator in the RadAjaxManagerProxy:

<telerik:RadAjaxManagerProxy runat="server" ID="RadAjaxManagerProxy">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="btnUpdate">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="btnUpdate" />                        
                <telerik:AjaxUpdatedControl ControlID="rfvAuditor" />        
            </UpdatedControls>
        </telerik:AjaxSetting>              
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>


The Grid in the parent control uses the User Control:
<EditFormSettings UserControlName="~/Controls/ComplianceFormAuditControl.ascx" EditFormType="WebUserControl">
                                                       <EditColumn UniqueName="EditCommandColumn1">
                                                       </EditColumn>
                                                   </EditFormSettings>

The Audit validation summary is available on the page:
<asp:ValidationSummary runat="server" ID="vsAudit" ForeColor="Red" ValidationGroup="Audit" />


The Rad Ajax Manager on the parent page is configured:
<telerik:AjaxSetting AjaxControlID="grdAudit">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="grdAudit" />
                <telerik:AjaxUpdatedControl ControlID="vsAudit" />
            </UpdatedControls>
        </telerik:AjaxSetting>


Doesn't seem to work. I have tried to manually call validation without success:
protected void grdAudit_InsertCommand(object sender, GridCommandEventArgs e)
        {
            Page.Validate("Audit");
            InsertUpdateAudits(e, ComplianceFormAuditEntity.Status.New);
        }


Any ideas?

3 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 19 Jun 2012, 11:58 PM
No one can assist?

Do I need additional information?

I need to get a RequiredFieldValidator to fire client-side inside a Rad Grid's User Control (EditFormSettings UserControlName). 

0
Accepted
Radoslav
Telerik team
answered on 21 Jun 2012, 06:15 AM
Hello Peter,

Could you please try using the following declaration of the RequiredFieldValidator and let me know if it helps you:
<asp:RequiredFieldValidator runat="server" ID="rfvAuditor" ControlToValidate="txtAuditor"
    ErrorMessage="Auditor is required" Display="Dynamic" ForeColor="Red" ValidationGroup="Audit"></asp:RequiredFieldValidator>

Additionally I am sending you a simple example based on your code.

I hope this helps.

All the best,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Peter
Top achievements
Rank 1
answered on 21 Jun 2012, 06:33 AM
Thanks for the example Radoslav.

Crucially I was missing the ValidationGroup="Audit" on the Insert button (and wasn't checking the Update function).
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or