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

RequiredFieldValidator is not validate radtextbox first submit

10 Answers 264 Views
Input
This is a migrated thread and some comments may be shown as answers.
Nguyen
Top achievements
Rank 1
Nguyen asked on 05 Apr 2013, 02:57 AM
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>

10 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 05 Apr 2013, 09:45 AM
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.
0
Nguyen
Top achievements
Rank 1
answered on 08 Apr 2013, 04:21 AM
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";
             
        }

0
Nguyen
Top achievements
Rank 1
answered on 10 Apr 2013, 04:15 AM
Do you have any suggestion with my code above ?
Thank you
0
Nguyen
Top achievements
Rank 1
answered on 15 Apr 2013, 06:39 AM
Look like no answer for my problem :(
0
Vasil
Telerik team
answered on 15 Apr 2013, 12:18 PM
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.
0
Nguyen
Top achievements
Rank 1
answered on 24 Apr 2013, 05:30 AM
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 = "";
        }
    }
}
0
Accepted
Vasil
Telerik team
answered on 26 Apr 2013, 02:30 PM
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.
0
Nguyen
Top achievements
Rank 1
answered on 30 Apr 2013, 01:29 PM
Thank, now it's working perfect with your solution
0
Newbie
Top achievements
Rank 1
answered on 11 Sep 2014, 01:35 PM
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.
0
Vasil
Telerik team
answered on 12 Sep 2014, 08:02 AM
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.

 
Tags
Input
Asked by
Nguyen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Nguyen
Top achievements
Rank 1
Vasil
Telerik team
Newbie
Top achievements
Rank 1
Share this question
or