Using a CustomValidator inside the EditTemplate of a FormView

2 posts, 0 answers
  1. Anders
    Anders avatar
    30 posts
    Member since:
    Jul 2013

    Posted 13 May 2015 Link to this post


    I try to validate two RadComboBox's which are placed inside the EditTemplate of a FormView. The server-side validation is working fine bit the Client-side is giving me troubles.

    It looks like that the RadComboBox are not yet available when the JavaScript is loaded. On this row of JavaScript:

    var combo = $find("<%= rcbFuelType.ClientID %>");

    I get this error message: Unknown identifier "rcbFuelType".


    The FormView is part of UserContrle and I have placed the Javascript inside the asp:content tag where the FormView is. I have also tried to place it inside the EditTemplate without any result.


    How can I get the this working?



    <script language="javascript" type="text/javascript">
        function ClientValidateFueltypes(source, arguments) {
            var combo = $find("<%= rcbFuelType.ClientID %>");
            var combo2 = $find("<%= rcbFuelType2.ClientID %>");
            if (combo.get_value() == "N.v.t.") {
                if (combo2.get_value() == "N.v.t.") {
                    arguments.IsValid = false;

  2. Eyup
    Eyup avatar
    3801 posts

    Posted 18 May 2015 Link to this post

    Hi Anders,

    Please have in mind that when a control is placed within a Content Page, RadGrid Template or another container which implements INamingContainer interface, its UniqueID and ClientID are modified, thus making it inaccessible on main Page level. On server-side, you need to use the FindControl method to access the control:
    ( Section Accessing controls in edit/insert mode )

    Alternatively, you can use the own event handler of the control itself and cast the sender object to the corresponding type.

    On-client side you can use the OnClientLoad event to get the sender object of the combo or the findControl method:

    Hope this helps.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top