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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--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" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>
            press enter key when the textbox has focus with empty string.
            <telerik:RadTextBox runat="server" ID="TextBox1" >
            </telerik:RadTextBox>
            <telerik:RadButton runat="server" ID="Button1" Text="do not click" UseSubmitBehavior="true"></telerik:RadButton>
     
            <asp:Label runat="server" ID="label1"></asp:Label>
        </div>
        <asp:RequiredFieldValidator ID="RequiredFieldValidatorTextBox1" runat="server"
            Display="None" SetFocusOnError="true" ErrorMessage="please type anything."
            ControlToValidate="TextBox1"
            ValidationGroup="test1"></asp:RequiredFieldValidator>
        <asp:ValidationSummary ID="ValidationSummarySave" runat="server" ShowSummary="false"
            ShowMessageBox="true" ValidationGroup="test1" />
        </form>
    </body>
    </html>
    Hello.

    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
    Admin
    Slav avatar
    1356 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:RadTextBox>
    <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."
        ControlToValidate="TextBox1"
        ValidationGroup="test1"></asp:RequiredFieldValidator>

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

    Kind regards,
    Slav
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top