UseSubmitBehavior and RequiredValidator problem

2 posts, 0 answers
  1. shunman
    shunman avatar
    77 posts
    Member since:
    Jul 2011

    Posted 28 Mar 2012 Link to this post

    <%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadControlsWebApp3._Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        <script type="text/javascript">
            //Put your JavaScript code here.
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            press enter key when the textbox has focus with empty string.
            <telerik:RadTextBox runat="server" ID="TextBox1" >
            <telerik:RadButton runat="server" ID="Button1" Text="do not click" UseSubmitBehavior="true"></telerik:RadButton>
            <asp:Label runat="server" ID="label1"></asp:Label>
        <asp:RequiredFieldValidator ID="RequiredFieldValidatorTextBox1" runat="server"
            Display="None" SetFocusOnError="true" ErrorMessage="please type anything."
        <asp:ValidationSummary ID="ValidationSummarySave" runat="server" ShowSummary="false"
            ShowMessageBox="true" ValidationGroup="test1" />

    I have a problem with RadButton UseSubmitBehavior property.

    I put the RadTextbox and RequiredValidator control.
    and set the UseSubmitBehavior ="true" on the Radbutton.

    when radtextbox is empty and i press enter key, the radbutton is not submitted like automatically click

    i'm using latest telerik hotfix version  ( 2012.1.320.40) and I had no problem since previous telerik version (2011.915)

    please let me know how to solve this problem.
    i'm attaching sample code.

  2. Slav
    Slav avatar
    1359 posts

    Posted 30 Mar 2012 Link to this post

    Hello Shunman,

    Note that the encountered behavior is expected and can be reproduced with regular Button and TextBox control as well. You can use the following sample if you want to trigger the click event of the RadButton, when the RadTextBox is empty:
    <telerik:RadTextBox runat="server" ID="TextBox1" >
        <ClientEvents OnKeyPress="OnKeyPress" />
    <telerik:RadButton runat="server" ID="Button1" Text="do not click"></telerik:RadButton>
    <asp:RequiredFieldValidator ID="RequiredFieldValidatorTextBox1" runat="server"
        Display="None" SetFocusOnError="true" ErrorMessage="please type anything."

    <script type="text/javascript">
        function OnKeyPress(sender, eventArgs) {
            var c = eventArgs.get_keyCode();
            if (c == 13)
                $find("<%=Button1.ClientID %>").click();

    Kind regards,
    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.
Back to Top