Validate a nested control

2 posts, 0 answers
  1. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 23 Dec 2009 Link to this post

    I have a RadComboBox that has a RadTreeView.  I would like to make the field required and am having a little trouble putting it together in my head.  I need to make sure that a non-root level node is selected in the tree.  Anyone have any advice on how to accomplish this?  I thinking that a RequiredFieldValidator is out of the question and I'll probably need to go the CustomValidator route. 
    Any help appreciated.


    Here is my markup:
    <telerik:RadComboBox ID="ProjectRadComboBox" AllowCustomText="True" EmptyMessage="[Choose One...]" 
        runat="server" Width="150px">  
        <ItemTemplate> 
            <div onclick="StopPropagation(event)">  
                <telerik:RadTreeView ID="ProjectRadTreeView" runat="server" DataTextField="project_name" 
                    DataValueField="project_id" DataFieldID="project_id" DataFieldParentID="fk_precinct_id" 
                    OnClientNodeClicking="OnClientNodeClickingHandler" OnNodeExpand="ProjectRadComboBox_NodeExpand" 
                    Height="300px">  
                </telerik:RadTreeView> 
            </div> 
        </ItemTemplate> 
        <Items> 
            <telerik:RadComboBoxItem runat="server" Text="[Choose One...]" Value="[Choose One...]" Selected="True" /> 
        </Items> 
    </telerik:RadComboBox> 

  2. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 23 Dec 2009 Link to this post

    Well I think it is as simple as adding a RequiredFieldValidator.

    <telerik:RadComboBox ID="ProjectRadComboBox" AllowCustomText="True" EmptyMessage="[Choose One...]" 
        runat="server" Width="150px">  
        <ItemTemplate> 
            <div onclick="StopPropagation(event)">  
                <telerik:RadTreeView ID="ProjectRadTreeView" runat="server" DataTextField="project_name" 
                    DataValueField="project_id" DataFieldID="project_id" DataFieldParentID="fk_precinct_id" 
                    OnClientNodeClicking="OnClientNodeClickingHandler" OnNodeExpand="ProjectRadComboBox_NodeExpand" 
                    Height="300px">  
                </telerik:RadTreeView> 
            </div> 
        </ItemTemplate> 
        <Items> 
            <telerik:RadComboBoxItem /> 
        </Items> 
    </telerik:RadComboBox> 
    <asp:RequiredFieldValidator ID="rfvProjects" runat="server" ControlToValidate="ProjectRadComboBox" 
        CssClass="error_message" Display="Dynamic" ErrorMessage="Required" InitialValue="[Choose One...]" 
        SetFocusOnError="True" ValidationGroup="sdg"></asp:RequiredFieldValidator> 
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top