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

UseSubmitBehavior and RequiredValidator problem

1 Answer 305 Views
Button
This is a migrated thread and some comments may be shown as answers.
shunman
Top achievements
Rank 1
shunman asked on 28 Mar 2012, 06:09 AM
<%@ 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.

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 30 Mar 2012, 03:03 PM
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.
Tags
Button
Asked by
shunman
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or