RequiredFieldValidator is not validate radtextbox first submit

11 posts, 1 answers
  1. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 04 Apr 2013 Link to this post

    Hi
    I have problem with RequiredFieldValidator, it's not validate at the first time when i click the submit button (search)

    But second time, when i click this button (search), it validate

     
    <telerik:RadWindow ID="rwAddStorage" runat="server" VisibleTitlebar="False" VisibleStatusbar="False"
            Modal="True" Behaviors="None" Width="500px" Behavior="None" Font-Size="14px"
            Height="610px">
            <ContentTemplate>
                <telerik:RadAjaxPanel ID="rapConfig" runat="server">
    <asp:Panel ID="Panel3" runat="server">
     <table border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <telerik:RadTextBox ID="txtSearchName" runat="server" EnableEmbeddedSkins="False"
                                                Width="260px" Skin="Inspire" EmptyMessage="Enter User Name for searching..."
                                                LabelCssClass="" LabelWidth="64px">
                                            </telerik:RadTextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Text="Storage Prefix is required"
                                                SetFocusOnError="True" ValidationGroup="SearchUser" ControlToValidate="txtSearchName"
                                                Style="display: none;"></asp:RequiredFieldValidator>
                                        </td>
                                        <td style="padding-left: 5px">
                                            <telerik:RadButton ID="btnSearch" runat="server" Text="Search" EnableEmbeddedSkins="False"
                                                ValidationGroup="SearchUser" Skin="Inspire" OnClick="btnSearch_Click">
                                            </telerik:RadButton>
                                            <telerik:RadButton ID="btnAddUser" runat="server" Text="Add" EnableEmbeddedSkins="False"
                                                Skin="Inspire" Enabled="false" OnClick="btnAddUser_Click">
                                                <Icon PrimaryIconCssClass="rbAdd"></Icon>
                                            </telerik:RadButton>
                                        </td>
                                    </tr>
                                </table>
    </asp:Panel>
                </telerik:RadAjaxPanel>
            </ContentTemplate>
        </telerik:RadWindow>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Apr 2013 Link to this post

    Hi,

    Please check the following mark-up I tried which works fine at my end. Validation is done at the first time when I click the Search button. I have removed few of your styles.

    ASPX:
    <telerik:RadButton ID="RadButton23" runat="server" Text="Open Window">
    </telerik:RadButton>
    <telerik:RadWindow ID="rwAddStorage" runat="server" VisibleTitlebar="False" VisibleStatusbar="False"
        OpenerElementID="RadButton23" Modal="True" Behaviors="None" Width="500px" Font-Size="14px"
        Height="400px">
        <ContentTemplate>
            <telerik:RadAjaxPanel ID="rapConfig" runat="server">
                <asp:Panel ID="Panel3" runat="server">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <telerik:RadTextBox ID="txtSearchName" runat="server" EnableEmbeddedSkins="False"
                                    Width="260px" Skin="Inspire" EmptyMessage="Enter User Name for searching..."
                                    LabelWidth="64px">
                                </telerik:RadTextBox>
                            </td>
                            <td style="padding-left: 5px">
                                <telerik:RadButton ID="btnSearch" runat="server" Text="Search" ValidationGroup="SearchUser"
                                    OnClick="btnSearch_Click">
                                </telerik:RadButton>
                                <telerik:RadButton ID="btnAddUser" runat="server" Text="Add" EnableEmbeddedSkins="False"
                                    Skin="Inspire" Enabled="false" OnClick="btnAddUser_Click">
                                    <Icon PrimaryIconCssClass="rbAdd"></Icon>
                                </telerik:RadButton>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Text="Storage Prefix is required"
                                    SetFocusOnError="true" ForeColor="Red" ValidationGroup="SearchUser" ControlToValidate="txtSearchName"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </telerik:RadAjaxPanel>
        </ContentTemplate>
    </telerik:RadWindow>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 07 Apr 2013 Link to this post

    I think the problem may be by AjaxPanel, when i put the button in side the panel it doesn't validate
    When i bring the button outside, it validate (but it validate only the first time, the next time i click the button, it still not validate)
    aspx:
     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadButton1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="radWindowtest" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
     <
    div>
            <telerik:RadPanelBar ID="rpbCompanyProfile" runat="server" Width="90%" BorderStyle="None"
                BorderWidth="0" CssClass="RadPanelBar1">
                <Items>
                    <telerik:RadPanelItem Expanded="true" Text="Company Profile" Font-Size="13pt">
                        <ContentTemplate>
                            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                                <asp:Panel ID="Panel2" runat="server">
                                    <telerik:RadButton ID="RadButton1" runat="server" Text="open rad window" OnClick="RadButton1_Click">
                                    </telerik:RadButton>
                                </asp:Panel>
                            </telerik:RadAjaxPanel>
                        </ContentTemplate>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelBar>
        </div>
         
     
        <telerik:RadWindow ID="radWindowtest" runat="server" VisibleTitlebar="False" VisibleStatusbar="true"
            Modal="True" Behaviors="None" Width="500px" Behavior="None" Font-Size="14px"
            Height="610px">
            <ContentTemplate>
                <telerik:RadAjaxPanel ID="rapTest" runat="server">
                    <asp:Panel ID="Panel1" runat="server">
                        <telerik:RadTextBox ID="txtTest" runat="server" EnableEmbeddedSkins="False" Width="260px"
                            Skin="Inspire" EmptyMessage="Enter User Name for searching...">
                        </telerik:RadTextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
                            ControlToValidate="txtTest" ValidationGroup="test" SetFocusOnError="true"></asp:RequiredFieldValidator>
                        <br />
                        <telerik:RadButton ID="RadButton2" runat="server" Text="RadButton" ValidationGroup="test"
                            OnClick="RadButton2_Click">
                        </telerik:RadButton>
                    </asp:Panel>
                </telerik:RadAjaxPanel>
            </ContentTemplate>
        </telerik:RadWindow>

    Code behind
    protected void RadButton1_Click(object sender, EventArgs e)
            {
                radWindowtest.VisibleOnPageLoad = true;
            }
     
            protected void RadButton2_Click(object sender, EventArgs e)
            {
                txtTest.Text = "Go to Server";
                 
            }

  5. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 09 Apr 2013 Link to this post

    Do you have any suggestion with my code above ?
    Thank you
  6. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 15 Apr 2013 Link to this post

    Look like no answer for my problem :(
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 15 Apr 2013 Link to this post

    Hi Nguyen,

    What version of RadControls are you using, and did you tried with the latest service pack? We have fixed an issue with the value on blur in RadInput that may be the same as you are facing.

    Regards,
    Vasil
    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.
  8. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 24 Apr 2013 Link to this post

    I have just update latest version.
    Resolution for my problem is remove ajax panel at the mother form
    But now i have facing another problem :(
    It just validate at the first time i submit, and second time when i submit it's not validate
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnOpen">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadWindow1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadButton ID="btnOpen" runat="server" Text="RadButton" OnClick="RadButton1_Click">
        </telerik:RadButton>
        <telerik:RadWindow ID="RadWindow1" runat="server">
            <ContentTemplate>
                <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">
                    <telerik:RadTextBox ID="RadTextBox1" runat="server">
                    </telerik:RadTextBox>
                    <telerik:RadButton ID="RadButton2" runat="server" Text="submit" ValidationGroup="Test" OnClick="RadButton2_Click">
                    </telerik:RadButton>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError="true"
                        ControlToValidate="RadTextBox1" ErrorMessage="*" ValidationGroup="Test"></asp:RequiredFieldValidator>
                </telerik:RadAjaxPanel>
            </ContentTemplate>
        </telerik:RadWindow>
    Code behind
    namespace Test_Telerik
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
     
            }
     
            protected void RadButton1_Click(object sender, EventArgs e)
            {
                RadWindow1.VisibleOnPageLoad = true;
                
            }
     
            protected void RadButton2_Click(object sender, EventArgs e)
            {
                RadTextBox1.Text = "";
            }
        }
    }
  9. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 26 Apr 2013 Link to this post

    Hi Nguyen,

    I see the issue, but it is not caused by the RadTextBox. If you place asp:TextBox you will get the same result.
    The problem is actually caused by mixing RadAjaxManager with RadAjaxPanel. These controls are using some common scripts and they should not be used in the same time.
    Place asp:Panel and ajaxify it using the manager, it will work correct.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnOpen">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadWindow1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    ...
    <telerik:RadWindow ID="RadWindow1" runat="server">
               <ContentTemplate>
                   <asp:Panel ID="Panel1" runat="server" Height="200px" Width="300px">


    All the best,
    Vasil
    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.
  10. Nguyen
    Nguyen avatar
    6 posts
    Member since:
    Jan 2013

    Posted 30 Apr 2013 Link to this post

    Thank, now it's working perfect with your solution
  11. Newbie
    Newbie avatar
    1 posts
    Member since:
    Sep 2014

    Posted 11 Sep 2014 Link to this post

    What all are required to enable a validation group in a radpanelbar? I had set the validation groups in the field validators and corresponging controls and the button control. On clicking, the field validators are not showing. Couldnt find a help online. Kindly help.
  12. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 12 Sep 2014 Link to this post

    Hello,

    The RadPanelBar has ValidationGroup property as well. You can see example of its usage in this demo: PanelBar - Validation Group

    I hope this helps. If you need further assistance, please explain your exact case in more details.

    Regards,
    Vasil
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017